C++ Programming Questions and Answers


C++ is a programming language that is part of the Object Oriented Programming System. This language was developed by Bjarne Stroustrup in 1985.

It uses abstraction of data using a concept named 'classes', among other features, to allow object-oriented programming. The main purpose of C++ programming was to add object-oriented concepts to the already available C programming.

In today's time, Object Oriented Programming is considered as the best in programming. Programs written in the C++ programming language can be run on operating systems such as Unix, Linux, Windows, etc.

Check some important C++ questions answers, which will help you in interview and exams.


Q 1. Which looping process is best used when the number of iterations is known ?
Ans. For loop
Q 2. Which keyword is used to define macros in C++ ?
Ans. #define
Q 3. The concept of oops allows compiler to insert arguments in a function call if it is not specified ?
Ans. Default arguments
Q 4. How many types of polymorphisms are supported by C++ ?
Ans. Two main types of polymorphism are run-time and compile-time
Q 5. Which term correctly describes overloading of functions ?
Ans. Ad-hoc polymorphism
Q 6. Which operator is overloaded for object cout ?
Ans. <<
Q 7. Which concepts means waiting until runtime to determine which function to call ?
Ans. Dynamic binding
Q 8. Which concepts is used to implement late binding ?
Ans. Virtual function
Q 9. Object oriented programming employs __________ programming approach ?
Ans. Bottom-up approach
Q 10. What happens if the base and derived class contains definition of a function with same prototype ?
Ans. Base class object will call base class function and derived class object will call derived class function.
Q 11. Which header file includes definition of 'cin' and 'cout' ?
Ans. iostream.h
Q 12. When a class is defined inside any function or block, it is called ?
Ans. Local class
Q 13. _________ is the OOP feature and mechanism that binds together code and the data it manipulates, and keep both safe from outside world ?
Ans. Data Encapsulation
Q 14. Classes in C++ are ?
Ans. User defined data types
Q 15. Which keyword is used to catch an exception in the code block ?
Ans. Try keyword
Q 16. Static variable declared in a class are also called ______ ?
Ans. Class variable
Q 17. What is the correct syntax to declare a pure virtual function ?
Ans. virtual void Display(void) = 0;
Q 18. True statements regarding inline functions ?
Ans. It speeds up execution but increase the code size
Q 19. Which operators cannot be overloaded in C++?
Ans. ?: and . operator
Q 20. Which statements allows you to overload a function in C++ ?
Ans. Type and number of arguments
Q 21. What is the default value of static variable ?
Ans. Zero
Q 22. _______ are used to format the data display in C++ ?
Ans. Manipulators
Q 23. The keyword 'void' is used to declare ?
Ans. A member function that is defined in a subclass
Q 24. When 'struct' is used instead of the 'class' keyword, will anything change in the program ?
Ans. Access is public by default
Q 25. What is the use of constructors in C++ ?
Ans. Initialize objects
Q 26. Which is an invalid visibility label while inheriting a class ?
Ans. Friend
Q 27. Turbo C++ library function can be used for ?
Ans. Write text in a various of fonts and sizes and draw lines and circles
Q 28. In C++, what will happen if a class is not having any name ?
Ans. It cannot have a constructor and destructor.
Q 29. Which keyword is used to overload an operator?
Ans. Operator keyword
Q 30. Which of the following escape sequences represents a tab ?
Ans. \t
Free Mock Test
Follow us on Facebook