Loading...

C++ Programming Interview Questions

This article is mainly focused on the most repeatedly asked and the latest updated questions.

C++ Interview Questions Set-3

Commonly Asked C++ Programming Interview Questions | Set 3


21. What are the OOPs concepts available in C++?
Ans:

  • Object
  • Class
  • Inheritance
  • Encapsulation
  • Abstraction
  • Polymorphism
More details


22. What is a default constructor in C++?
Ans: Constructor that doesn't take any arguments is called default constructor, i.e it has no parameters. Even if we do not define any constructor explicitly, the compiler will automatically provide a default constructor implicitly.


23. What is the function of the keyword “Volatile”?
Ans: "Volatile" is a function that helps in declaring that the particular variable is volatile and thereby directs the compiler to change the variable externally- this way, the compiler optimization on the variable reference can be avoided.


24. What is a destructor?
Ans: A destructor is the member function of the class. It has the same name as the class name and also prefixed with a tilde symbol. It can be executed automatically whenever an object loses its scope.


25. Define token in C++.
Ans: A token in C++ can be a keyword, identifier, literal, constant and symbol.


26. Define storage class in C++? Name some?
Ans: Storage class in C++ specifically resemble life or even the scope of symbols, including the variables, functions, etc. Some of the storage class names in C++ include mutable, auto, static, extern, register, etc.


27. Define 'std'.
Ans: Std is the default namespace standard used in C++. It is a library that allows you to use a standard set of templates for things such as: Algorithms, functions, Iterators in place of actual code.


28. What is the full form of STL in C++?
Ans: STL stands for Standard Template Library.


29. What is the difference between an array and a list?
Ans:

  • An Array is a collection of homogeneous elements while a list is a collection of heterogeneous elements.
  • Array memory allocation is static and continuous while List memory allocation is dynamic and random.
  • In Array, users don't need to keep in track of next memory allocation while In the list, the user has to keep in track of next location where memory is allocated.


30. What is function overloading in C++?
Ans: Function Overloading happens in C++ when two or more functions share the same name. They can be differentiated on the basis of the type of data they are passing as parameters or even the number of paramters they are passing. eg. int fun(char a); & int fun(int b); & void fun(int a, int b).


- Related Topics