C++ Technical Interview Questions and Answers - 1

Question: 1

Explain virtual class and friend class?

Virtual Base Class:

It is used in context of multiple inheritance in C++.

If you want to derive two classes from a class, and further derive one class from the two classes in the second level, you need to declare the uppermost base class as “virtual” in the inherited classes. These prevent multiple copies of the uppermost base class data members when an object of the class at the third level of hierarchy is created.

Friend Class: When a class declares another class as its friend, it is giving complete access to all its data and methods including private and protected data and methods to the friend class member methods.

Question: 2

How many fundamental data types are there?


Float and

Void are the three fundamental data types.

Question: 3

What are the rules to be followed while writing variable name?

A variable must begin with an alphabet or underscore followed by alphabets or numbers.

Question: 4

How many words are there for data types and what are they?

There are nine words for data types such as








long and


Question: 5

When is the variable called as garbage?

When the variables get undefined values known as garbage.

Related Questions