Loading...

C++ Programming Interview Questions

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

C++ Interview Questions Set-1

Commonly Asked C++ Programming Interview Questions | Set 1


1. What is C++ language?
Ans: C++ is an object-oriented programming language created by Bjarne Stroustrup. It was released in 1985.

  • C++ is a superset of C with the major addition of classes in C language.
  • Initially, Stroustrup called the new language "C with classes". However, after sometime the name was changed to C++. The idea of C++ comes from the C increment operator ++.


2. Can we call C++ OOPS? and Why?
Ans: Yes, C++ can be called OOPS. The full form of OOPS is an Object-Oriented Programming System, which means a paradigm that provides an application of various concepts, including data binding, polymorphism, inheritance, and various others.


3. What is scope of a variable? How are variables scoped in C++?
Ans: Scope of a variable is the part of the program where the variable may directly be accessible. In C++, all identifiers are lexically (or statically) scoped. More details.


4. What are the key features in the C++ programming language?
Ans: Features are as follows:

  • Simple - It is a simple language in the sense that programs can be broken down into small parts, has a rich liberary support and a variety of data-types.
  • Machine Independent but not Platform Dependent - C++ executable is not platform-independent (compiled programs on Linux won't run on Windows), however it is machine independent.
  • Middle-level Language - It is a Middle-level language, as we can do both systems-programming (drivers, kernels, networkinf etc.) and build large-scale user applications(Photoshop, Game Engines, Media Players etc.).
  • Compiled Language - C++ is a compiled language, contributing to its speed.
  • Faster execution - C++ programs excel in execution speed. Since, it is a compiled language, and also higely procedural.


5. What are the basic data types associated with C++?
Ans:

  • Int – Represent the number (integer)
  • Float – Number with a fraction part.
  • Double – Double-precision floating-point value
  • Char – Single character
  • Void – Special purpose type without any value.


6. Define Class in C++?
Ans: Class is referred to as the designing of the user-defined data type. It reflects the different entities, attributes, and actions.


7. Define Object in C++?
Ans: Object is an instance of the class. An object can have fields, methods, constructors, and related. For example, a bike in real life is an object, but it has various features such as brakes, color, size, design, and others, which are instances of its class.


8. What is function in C++?
Ans: A function in C++ is a block of code that can be referenced from anywhere in the system and that serves a specific purpose. More details.


9. Define a namespace?
Ans: A namespace is used for resolving the name conflict of the identifier, which is accomplished by placing them under various namespaces. This way, it helps in the logical division of the different codes.


10. How many keywords in C++ ?
Ans: There are 95 reserved keywords in C++ which are not available for re-definition or overloading.


- Related Topics