Top 80+ Solved CPP Programming MCQ Questions Answer
Q. A member function can always access the data in __________, (in C++).
a. the class of which it is member
b. the object of which it is a member
c. the public part of its class
d. the private part of its class
Q. Which of the following is not correct for virtual function in C++?
a. Must be declared in public section of class.
b. Virtual function can be static.
c. Virtual function should be accessed using pointers.
d. Virtual function is defined in base class.
Q. Which of the following is not correct (in C++)?1. Class templates and function templates are instantiated in the same way2. Class templates differ from function templates in the way they are initiated3. Class template is initiated by defining an object using the template argument4. Class templates are generally used for storage classes
a. (1)
b. (2), (4)
c. (2), (3), (4)
d. (4)
Q. Which of the following cannot be passed to a function in C++?
a. Constant
b. Structure
c. Array
d. Header file
Q. Which of the following, in C++, is inherited in a derived class from base class?
a. Constructor
b. Destructor
c. Data members
d. Virtual methods
Q. Which of the following is a correct statement?
a. Composition is a strong type of association between two classes with full ownership.
b. Composition is a strong type of association between two classes with partial ownership.
c. Composition is a weak type of association between two classes with partial ownership.
d. Composition is a weak type of association between two classes with strong ownership.
Q. Which of the following is not a correct statement?
a. Every class containing abstract method must be declared abstract.
b. Abstract class can directly be initiated with ‘new’ operator.
c. Abstract class can be initiated.
d. Abstract class does not contain any definition of implementation.
Q. When a method in a subclass has the same name and type signatures as a method in thesuperclass, then the method in the subclass _____ the method in the superclass.
a. Overloads
b. Friendships
c. Inherits
d. Overrides
Q. When one object reference variable is assigned to another object reference variable then
a. a copy of the object is created.
b. a copy of the reference is created.
c. a copy of the reference is not created.
d. it is illegal to assign one object reference variable to another object reference variable.
Q. Which of the following is not a member of class?
a. Static function
b. Friend function
c. Const function
d. Virtual function
Q. How can we restrict dynamic allocation of objects of a class using new?
a. By overloading new operator
b. By making an empty private new operator.
c. By making an empty private new and new[] operators
d. By overloading new operator and new[] operators
Q. Which of the following operators cannot be overloaded?
a. . (Member Access or Dot operator)
b. ?: (Ternary or Conditional Operator)
c. :: (Scope Resolution Operator)
d. All of the above
Q. Which of the following operators are overloaded by default by the compiler in every user defined classes even if user has not written? 1) Comparison Operator (==) 2) Assignment Operator (=)
a. Both 1 and 2
b. Only 1
c. Only 2
d. None of the two
Q. Which of the following operators should be preferred to overload as a global function rather than a member method?
a. Postfix ++
b. Comparison Operator
c. Insertion Operator <<
d. Prefix++