Monday, August 23, 2010

C++ INterview Questions and Answers

1. What is the difference between an ARRAY and a LIST?


Array is collection of homogeneous elements.
List is collection of heterogeneous elements.

For Array memory allocated is static and continuous.
For List memory allocated is dynamic and Random.

Array: User need not have to keep in track of next memory allocation.
List: User has to keep in Track of next location where memory is allocated.

2. Does c++ support multilevel and multiple inheritance?

Ans: Yes.

3. What do you mean by inheritance?

Ans: Inheritance is the process of creating new classes, called derived classes, from existing classes or base classes. The derived class inherits all the capabilities of the base class, but can add embellishments and refinements of its own.

4. What is a COPY CONSTRUCTOR and when is it called?

Ans: A copy constructor is a method that accepts an object of the same class and copies it’s data members to the object on the left part of assignement:

5. What is virtual class and friend class?

Ans: Friend classes are used when two or more classes are designed to work together and need access to each other's implementation in ways that the rest of the world shouldn't be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class DatabaseCursor to have more privilege to the internals of class Database than main() has.

No comments: