C++ Interview Questions & Answers

  • Home
  • Interview_Question

Interview Questions & Answers

Select Series

How a negative integer is stored.

Get the two’s compliment of the same positive integer. Eg: 1011 (-5) Step-1 − One’s compliment of 5 : 1010 Step-2 − Add 1 to above, giving 1011, which is -5

What is the difference between actual and formal parameters?

The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.

Where an automatic variable is stored?

Every local variable by default being an auto variable is stored in stack memory.

How does bitwise operator XOR works.

If both the corresponding bits are same it gives 0 else 1.

Explain about ‘stdin’.

stdin in a pointer variable which is by default opened for standard input device.

What is recursion?

Function calling itself is called as recursion.

Which built-in library function can be used to match a patter from the string?


Can one function call another?

Yes, any user defined function can call any function.

What is the full form of OOPS?

Object Oriented Programming System.

What is inheritance?

Inheritance is the process of acquiring the properties of the exiting class into the new class. The existing class is called as base/parent class and the inherited class is called as derived/child class.

Distinguish between shallow copy and deep copy.

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.

Explain the static member function.

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.

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

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

What is the difference between the keywords struct and class in C++?

By default the members of struct are public and by default the members of the class are private.

Can we implement all the concepts of OOPS using the keyword struct?


Where an automatic variable is stored?

Every local variable by default being an auto variable is stored in stack memory

What is the first string in the argument vector w.r.t command line arguments?

Program name.

Can we create and empty class? If so what would be the size of such object.

We can create an empty class and the object size will be 1.

Is 068 a valid octal number?

No, it contains invalid octal digits.

What is a friend class?

A class members can gain accessibility over other class member by placing the class declaration prefixed with the keyword ‘friend’ in the destination class.