Top 80+ Solved CPP Programming MCQ Questions Answer
Q. How C++ compiler does differ between overloaded postfix and prefix operators?
a. C++ doesn’t allow both operators to be overloaded in a class
b. A postfix ++ has a dummy parameter
c. A prefix ++ has a dummy parameter
d. By making prefix ++ as a global function and postfix as a member function.
Q. Which of the following operator functions cannot be global?
a. new
b. delete
c. Conversion Operator
d. All of the above
Q. Which of the following is true about this pointer?
a. It is passed as a hidden argument to all function calls
b. It is passed as a hidden argument to all non-static function calls
c. It is passed as a hidden argument to all static functions
d. None of the above
Q. What is the use of this pointer?
a. When local variable’s name is same as member’s name, we can access member using this pointer.
b. To return reference to the calling object
c. Can be used for chained function calls on an object
d. All of the above
Q. Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++?
a. Inheritance
b. Polymorphism
c. Encapsulation
d. None of the above
Q. Which of the following is true about templates?1) Template is a feature of C++ that allows us to write one code for different data types.2) We can write one function that can be used for all data types including user defined types. Like sort(), max(), min(), ..etc.3) We can write one class or struct that can be used for all data types including user defined types. Like Linked List, Stack, Queue,..etc.4) Template is an example of compile time polymorphism.
a. 1 and 2
b. 1, 2 and 3
c. 1, 2 and 4
d. 1, 2, 3 and 4
Q. Which of the following is incorrect in C++?(1)When we write overloaded function we must code the function for each usage.(2)When we write function template we code the function only once.(3)It is difficult to debug macros(4)Templates are more efficient than macros
a. (1) and (2)
b. (1), (2) and (3)
c. (3) and (4)
d. All are correct.
Q. Which type is best suited to represent the logical values?
a. integer
b. Boolean
c. character
d. all of the mentioned
Q. Identify the user-defined types from the following?
a. enumeration
b. classes
c. both enumeration and classes
d. int
Q. Which of the following statements are true? int f (float)
a. f is a function taking an argument of type int and returning a floating point number
b. f is a function taking an argument of type float and returning an integer
c. f is a function of type float
d. none of the mentioned