Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

Explain the pointer – this.

Answer»

This, is the pointer variable of the compiler which always holds the current active object’s address.

52.

Does C++ supports exception handling? If so what are the keywords involved in achieving the same.

Answer»

C++ does supports exception handling. try, catch & throw are keyword used for the same.

53.

What is a friend function?

Answer»

A function which is not a member of the class but still can access all the member of the class is called so. To make it happen we need to declare within the required class following the keyword ‘friend’.

54.

Can I use ‘delete’ operator to release the memory which was allocated using malloc() function of C language?

Answer»

No, we need to use free() of C language for the same.

55.

Can I use malloc() function of C language to allocate dynamic memory in C++?

Answer»

Yes, as C is the subset of C++, we can all the functions of C in C++ too.

56.

What is the purpose of ‘delete’ operator?

Answer»

‘delete’ operator is used to release the dynamic memory which was created using ‘new’ operator.

57.

Which operator can be used in C++ to allocate dynamic memory?

Answer»

‘new’ is the operator can be used for the same.

58.

What is a default constructor? Can we provide one for our class?

Answer»

Every class does have a constructor provided by the compiler if the programmer doesn’t provides one and known as default constructor. A programmer provided constructor with no parameters is called as default constructor. In such case compiler doesn’t provides the constructor.

59.

What is a destructor? Can it be overloaded?

Answer»

A destructor is the member function of the class which is having the same name as the class name and prefixed with tilde (~) symbol. It gets executed automatically w.r.t the object as soon as the object loses its scope. It cannot be overloaded and the only form is without the parameters.

60.

When a class member is defined outside the class, which operator can be used to associate the function definition to a particular class?

Answer»

Scope resolution operator (::)

61.

Which access specifier/s can help to achive data hiding in C++?

Answer»

Private & Protected.

62.

Name the default standard streams in C++.

Answer»

cin, cout, cerr and clog.

63.

Do we have a String primitive data type in C++?

Answer»

No, it’s a class from STL (Standard template library).

64.

What is the data type to store the Boolean value?

Answer»

bool, is the new primitive data type introduced in C++ language.

65.

Can we initialize a class/structure member variable as soon as the same is defined?

Answer»

No, Defining a class/structure is just a type definition and will not allocated memory for the same.

66.

What are/is the operator/operators used to access the class members?

Answer»

Dot (.) and Arrow ( -> )

67.

Name the data type which can be used to store wide characters in C++.

Answer»

wchar_t

68.

Explain the static member function.

Answer»

A static member function can be invoked using the class name as it exits before class objects comes into existence. It can access only static members of the class.

69.

What is role of static keyword on class member variable?

Answer»

A static variable does exit though the objects for the respective class are not created. Static member variable share a common memory across all the objects created for the respective class. A static member variable can be referred using the class name itself.

70.

What is a reference variable in C++?

Answer»

A reference variable is an alias name for the existing variable. Which mean both the variable name and reference variable point to the same memory location. Therefore updation on the original variable can be achieved using reference variable too.

71.

What is an abstract class in C++?

Answer»

A class with at least one pure virtual function is called as abstract class. We cannot instantiate an abstract class.

72.

What is a pure virtual function?

Answer»

A virtual function with no function body and assigned with a value zero is called as pure virtual function.

73.

Distinguish between shallow copy and deep copy.

Answer»

Shallow copy does memory dumping bit-by-bit from one object to another. Deep copy is copy field by field from object to another. Deep copy is achieved using copy constructor and or overloading assignment operator.

74.

What is the role of mutable storage class specifier?

Answer»

A constant class object’s member variable can be altered by declaring it using mutable storage class specifier. Applicable only for non-static and non-constant member variable of the class.

75.

Mention the storage classes names in C++.

Answer»

The following are storage classes supported in C++

auto, static, extern, register and mutable

76.

What is a storage class?

Answer»

Storage class specifies the life or scope of symbols such as variable or functions.

77.

What is an inline function?

Answer»

A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros.

78.

Explain the purpose of the keyword volatile.

Answer»

Declaring a variable volatile directs the compiler that the variable can be changed externally. Hence avoiding compiler optimization on the variable reference.

79.

What is the role of protected access specifier?

Answer»

If a class member is protected then it is accessible in the inherited class. However, outside the both the private and protected members are not accessible.

80.

List the types of inheritance supported in C++.

Answer»

Single, Multilevel, Multiple, Hierarchical and Hybrid.

81.

What is the full form of OOPS?

Answer»

Object Oriented Programming System.