C++ Interview Questions and Answers

What is C++?
C++ is an object oriented programming language created by Barnes Stroustrup. It is released in 1985.

What is the ADVANTAGES of C++
C++ doesn’t only maintains all aspects from C language, it also simplify memory management and add several features like:
Includes a new data type known as a class.
Allows object oriented programming.

What is full form of OOPS?
Object Oriented Programming System

What is a class?
Class is a collection of objects technically defining a class is designing an user defined data type.

What is an object?
An instance of the class is called as object. Or real time entity

What is abstraction?
The technique of creating user-defined data types, having the properties of built-in data types and a set of permitted operators that are well suited to the application to be programmed is known as data abstraction. Class is a construct for abstract data types (ADT).

What is encapsulation?
It is the mechanism that warping up of data and function into a single unit.

What is polymorphism?
Is a feature of OOPL that at run time depending upon the type of object the appropriate method is called?

What is inheritance?
Inheritance is the process of acquiring the properties of the exiting class into the new class. The existing class is called as base/parent class and the inherited class is called as derived/child class.

List the types of inheritance supported in C++.






What are the c++ tokens?
c++ has the following tokens
I. keywords
II. Identifiers
III. Constants
IV. Strings
V. operators

What is the difference between Array and List?
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.

What do you mean by reference variable in c++?
A reference variable provides an alias to a previously defined variable.
Data type & reference-name = variable name

What is the difference between method overloading and method overriding?
Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.

What is function overloading?
Defining several functions with the same name with unique list of parameters is called as function overloading.

What is operator overloading?
Defining a new job for the existing operator w.r.t the class objects is called as operator overloading.

What do you mean by inline function?
An inline function is a function that is expanded inline when the compiler replaces the function call with the corresponding function code. An inline function is a function that is expanded in line when it is invoked. That is the compiler replaces the function call with the corresponding function code (similar to macro).

What is Static Member?
Static is a keyword in C++ used to give special characteristics to an element. Static elements are allocated storage only once in a program lifetime in static storage area. And they have a scope till the program lifetime.

What is a copy constructor?
A copy constructor is the constructor which take same class object reference as the parameter. It gets automatically invoked as soon as the object is initialized with another object of the same class at the time of its creation.

Function calling itself is called as recursion.

Is it possible to have a recursive inline function?
We can call an inline function from within itself; the compiler may not generate inline code since the compiler cannot determine the depth of recursion at compile time. A compiler with a good optimizer can inline recursive calls till some depth fixed at compile-time and insert non-recursive calls at compile time for cases when the actual depth gets exceeded at run time.