0% found this document useful (0 votes)
37 views1 page

Answer All Questions.: N R N R

The document contains 18 questions related to object-oriented programming concepts in C++ including class constructors, access specifiers, friend functions, memory allocation, and classes. Key topics covered are: 1. The class construct enables data security by encapsulating data within a class and controlling access via access specifiers. 2. The scope resolution operator :: is used to access members of a namespace or class from outside their scope. 3. The "this" pointer refers to the current object instance and is implicitly used by member functions to access data members and other members of the class for the current object. 4. Data abstraction hides implementation details and exposes only essential functions and properties to the user through a clear

Uploaded by

Bean Shinchan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

Answer All Questions.: N R N R

The document contains 18 questions related to object-oriented programming concepts in C++ including class constructors, access specifiers, friend functions, memory allocation, and classes. Key topics covered are: 1. The class construct enables data security by encapsulating data within a class and controlling access via access specifiers. 2. The scope resolution operator :: is used to access members of a namespace or class from outside their scope. 3. The "this" pointer refers to the current object instance and is implicitly used by member functions to access data members and other members of the class for the current object. 4. Data abstraction hides implementation details and exposes only essential functions and properties to the user through a clear

Uploaded by

Bean Shinchan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Answer all questions.

1. How does the class construct enable data security?


2. Elaborate the use of the scope resolution operator in C++?
3. What is the “this” pointer? Where and why does the compiler insert it implicitly?
Explain it with details
4. What is data abstraction? How is it implemented in C++?
5. Write a C++ program to define a class called Time with hour, minute and second as
the data members and read(), display() and add() as the member functions.
6. Illustrate C++ program for a) passing objects to functions b) returning objects.
7. Why should default values be given to function argument in function prototype?
Explain with example.
8. How can a global non-member function be declared as a friend to a class? Show with
an example.
9. What is the use of declaring a class as a friend of another? Explain it with an example.
10. Explain why friend functions do not contradict the principles of OOPS.
11. What is static memory allocation? When is memory allocated and deallocated in static
memory allocation—during compile time or run time? Explain it. Under what
conditions does static memory allocation become unsuitable?
12. What is dynamic memory allocation? How is it different from static memory
allocation? Explain it. Under what conditions does the use of dynamic memory
allocation become mandatory?
13. What is memory leak? How can the delete operator be used to prevent a memory
leak?
14. What is an inline function in C++? Explain the advantage of inline function over
macro definition in C? Write an inline function that converts a temperature given in
Centigrades to degree Fahrenheit.
15. Write an interactive C++ program to accept two positive integer numbers n and r and
computes nCr and nPr where:

16. What are constructors and when they are called? Why should the formal argument of
a copy constructor be a reference object?
17. What is the advantage of copy constructor? Explain with an example the necessity of
defining our own copy constructor though default copy constructor exists.
18. Write the following class called ‘Student-Data’ that uses a pointer to store personal
data of a student who studies in a University. The class has two types of information:
common data to all the students like name of the University and name of the section.
For each student there is a personal data accessible through a pointer. Write a program
that creates an object SO1 of Student-Data type, reads its data, copies the object to
another object SO2 and prints the data of both the objects. Thereafter, it modifies the
personal data of SO2 and prints the data of both the objects.

You might also like