Operational C++ Programmer Interview Preparation Guide
Download PDF

C++ Programmer related Frequently Asked Questions by expert members with professional career as C++ Programmer. These list of interview questions and answers will help you strengthen your technical skills, prepare for the new job interview and quickly revise your concepts

59 C++ Programmer Questions and Answers:

Table of Contents:

Operational  C++ Programmer Job Interview Questions and Answers
Operational C++ Programmer Job Interview Questions and Answers

1 :: Tell us what do you mean by internal linking and external linking in c++?

A symbol is said to be linked internally when it can be accessed only from with-in the scope of a single translation unit. By external linking a symbol can be accessed from other translation units as well. This linkage can be controlled by using static and extern keywords.

2 :: Explain what do you mean by pure virtual functions in C++?

Pure virtual function is a function which doesn't have an implementation and the same needs to be implemented by the the next immediate non-abstract class. (A class will become an abstract class if there is at-least a single pure virtual function and thus pure virtual functions are used to create interfaces in c++).

3 :: Tell me what is an abstract class in C++?

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

4 :: Do you know the purpose of the keyword volatile?

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

5 :: Tell me what is this pointer?

The ‘this’ pointer is passed as a hidden argument to all nonstatic member function calls and is available as a local variable within the body of all nonstatic functions. ‘this’ pointer is a constant pointer that holds the memory address of the current object. ‘this’ pointer is not available in static member functions as static member functions can be called without any object (with class name).

6 :: Explain what is the role of protected access specifier?

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.

7 :: Please explain what is a reference variable in C++?

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.

8 :: What is an inline function in C++?

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.

9 :: Tell me what do you mean by persistent and non persistent objects?

Persistent objects are the ones which we can be serialized and written to disk, or any other stream. So before stopping your application, you can serialize the object and on restart you can deserialize it. [ Drawing applications usually use serializations.]
Objects that can not be serialized are called non persistent objects. [ Usually database objects are not serialized because connection and session will not be existing when you restart the application. ]

10 :: Tell me the types of inheritance supported in C++?

☛ Single,
☛ Multilevel,
☛ Multiple,
☛ Hierarchical and
☛ Hybrid.

11 :: Explain me the storage classes names in C++?

The following are storage classes supported in C++

☛ auto,
☛ static,
☛ extern,
☛ register and
☛ mutable

12 :: Tell me the default standard streams in C++?

☛ cin,
☛ cout,
☛ cerr and
☛ clog.

13 :: Do you know what is encapsulation?

The process of binding the data and the functions acting on the data together in an entity (class) called as encapsulation.

14 :: Please explain the volatile and mutable keywords?

The volatile keyword informs the compiler that a variable may change without the compiler knowing it. Variables that are declared as volatile will not be cached by the compiler, and will thus always be read from memory.

The mutable keyword can be used for class member variables. Mutable variables are allowed to change from within const member functions of the class.

15 :: Explain void* realloc (void* ptr, size_t size)?

This function is used to change the size of memory object pointed by address ptr to the size given by size. If ptr is a null pointer, then realloc will behave like malloc(). If the ptr is an invalid pointer, then defined behaviour may occur depending the implementation. Undefined behaviour may occur if the ptr has previously been deallocated by free(), or dealloc() or ptr do not match a pointer returned by an malloc(), calloc() or realloc().

16 :: Explain me what is implicit conversion/coercion in c++?

Implicit conversions are performed when a type (say T) is used in a context where a compatible type (Say F) is expected so that the type T will be promoted to type F.
short a = 2000 + 20;
In the above example, variable a will get automatically promoted from short to int. This is called implicit conversion/coercion in c++.

17 :: Explain me what is virtual destructors? Why they are used?

Virtual destructors are used for the same purpose as virtual functions. When you remove an object of subclass, which is referenced by a parent class pointer, only destructor of base class will get executed. But if the destructor is defined using virtual keyword, both the destructors [ of parent and sub class ] will get invoked.

18 :: Do you know what is an object?

An instance of the class is called as object.

19 :: Tell me what is the block scope variable in C++?

A variable whose scope is applicable only within a block is said so. Also a variable in C++ can be declared anywhere within the block.

20 :: Tell me what is the full form of OOPS?

Object Oriented Programming System.

21 :: Tell us what is a storage class?

A class that specifies the life and scope of its variables and functions is called a storage class.

In C++ following the storage classes are supported: auto, static, register, extern, and mutable.

Note, however, that the keyword register was deprecated in C++11. In C++17, it was removed and reserved for future use.

23 :: Tell me do we have a String primitive data type in C++?

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

24 :: What is a storage class in C++?

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

25 :: Tell me what is abstraction?

Abstraction refers to hiding the internal implementation and exhibiting only the necessary details.
C++ Programmer Interview Questions and Answers
59 C++ Programmer Interview Questions and Answers