Interview Questions C++


1. What is C++
C++ is created by BjarneStroustrup of AT&T Bell Labs as an extension of C, C++ is an object-oriented computer language used in the development of enterprise and commercial applications. Microsoft's Visual C++ became the premier language of choice among developers and programmers.

2. What the basic concepts are of object oriented programming?
It is necessary to understand some of the concepts used extensively in object oriented programming.These include
a. Objects
b. Classes
c. Data abstraction and encapsulation
d. Inheritance
e. Polymorphism
f. Dynamic Binding
g. Message passing

3. Define inheritance?
The mechanism of deriving a new class (derived) from an old class (base class) is called inheritance. It allows the extension and reuse of existing code without having to rewrite the code from scratch. Inheritance is the process by which objects of one class acquire properties of objects of another class.

4. Define polymorphism?
Polymorphism means one name, multiple forms. It allows us to have more than one function with the same name in a program.It allows us to have overloading of operators so that an operation can exhibit different behaviours in different instances.

5. What are the features of C++ different from C?
a. All the features of C issimilar to C++ except some features, such as polymorphism, operator overloading which are supported in C++ but not in C language.
b. Both C and C++ language is similiar in their functionality but C++ provides with more tools and options.

6. What is encapsulation?
The wrapping up of data and functions into a single unit (called class) is known as encapsulation. Encapsulation containing and hiding information about an object, such as internal data structures and code.

7. What is message passing?
An object oriented program consists of a set of objects that communicate with each other. Message passing involves specifying the name of the object, the name of the function and the information to be sent.

8. What are tokens in C++?
The smallest individual units of a program is known as tokens. c++ has the following tokens :
a. Keywords
b. Identifiers
c. Constants
d. Strings
e. Operators

9. What is the use of enumerated data type?
An enumerated data type is another user defined type which provides a way for attaching names to numbers thereby increasing comprehensibility of the code. The enum keyword automatically enumerates a list of words by assigning those values 0,1,2, and so on.

10. What is the use of default constructor?
A constructor that accepts no parameters is called the default constructor. If no user-defined constructor exists for a class A and one is needed, the compiler implicitly declares a default parameter less constructor A::A(). This constructor is an inline public member of its class. The compiler will implicitly define A::A() when the compiler uses this constructor to create an object of type A. The constructor will have no constructor initializer and a null body.