CPP Interview Questions | CPP Interview Questions and Answers

CPP Interview Questions

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

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.

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.

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.

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.

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.

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

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.

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.

A constructor is a member function with the same name as its class. The constructor is invoked whenever an object of its associated class is created.It is called constructor because it constructs the values of data members of the class.

All rights reserved by WsCube Tech