Question-81. What are the C++ access specifiers ?

Answer- The access specifiers are used to define how to functions and variables can be accessed outside the class.

There are three types of access specifiers:

Private: Functions and variables declared as private can be accessed only within the same class 
and they cannot be accessed outside the class they are declared.
Public: Functions and variables declared under public can be accessed from anywhere.
Protected: Functions and variables declared as protected cannot be accessed outside the class except 
a child class. This specifier is generally used in inheritance.

 

Question-82. What is Object Oriented Programming (OOP) ?

Answer- OOP is a methodology or paradigm that provides many concepts. The basic concepts of Object Oriented Programming are given below:

Classes and Objects: Classes are used to specify the structure of the data. They define datatype. 
You can create any number of objects from a class. Objects are the instances of classes.
Encapsulation: Encapsulation is a mechanism which binds the data and associated operations together and 
thus hide the data from outside world. Encapsulation is also known as data hiding. 
In C++, It is achieved using the access specifiers i.e. public, private and protected .
Abstraction: Abstraction is used to hide the internal implementations and show only the necessary details 
to the outer world. Data abstraction is implemented using interfaces and abstract classes in C++.
Some people confused about Encapsulation and abstraction. But they both are different.

Inheritance: Inheritance is used to inherit the property of one class into another class. It facilitates 
you to define one class in term of another class.

 

Question-82. What is the difference between array and a list ?

Answer- Array is a collection of homogeneous elements while list is a collection of heterogeneous elements. Array memory allocation is static and continuous while List memory allocation is dynamic and random. In Array, users don’t need to keep in track of next memory allocation while In list user has to keep in track of next location where memory is allocated.

 

Question-83. What is the difference between new() and malloc() ?

Answer- new() is a preprocessor while malloc() is a function.
There is no need to allocate the memory while using “new” but in malloc() you have to use sizeof(). “new” initializes the new memory to 0 while malloc() gives random value in the newly allotted memory location.

 

Question-84. What are the methods of exporting a function from a DLL ?

Answer- There are two ways:

By using the DLL’s type library.
Taking a reference to the function from the DLL instance.

Question-85. What is virtual function ?

Answer- A virtual function is used to replace the implementation provided by the base class. The replacement is always called whenever the object in question is actually of the derived class, even if the object is accessed by a base pointer rather than a derived pointer.

 

Question-86. When should we use multiple inheritance ?

Answer- You can answer this question in three manners:

Never
Rarely
If you find that the problem domain cannot be accurately modeled any other way.

Question-87. What is an overflow error? ?

Answer- It is a type of arithmetical error. It is happen when the result of an arithmetical operation been greater than the actual space provided by the system.

 

Question-88. What is virtual inheritance ?

Answer- Virtual inheritance facilitates you to create only one copy of each object even if the object appears more than one in the hierarchy.

 

Question-89. What does Scope Resolution operator ?

Answer- A scope resolution operator(::) is used to define the member function outside the class.[/vc_column_text][/vc_column][/vc_row]