CPP MCQ
MCQ
• Which of the following is a valid class declaration?
a) class A { int x; };
b) class B { }
c) public class A { }
d) object A { int x; };
• Which of the following is a valid class declaration?
a) class A { int x; };
b) class B { }
c) public class A { }
d) object A { int x; };
MCQ
• Which of the following features must be supported by any
programming language to become a pure object-oriented
programming language?
1.Encapsulation
2.Inheritance
3.Polymorphism
4.All of the above
MCQ
• Which of the following features must be supported by any
programming language to become a pure object-oriented
programming language?
1.Encapsulation
2.Inheritance
3.Polymorphism
4.All of the above
MCQ
• How many data members can a class contain?
a) 27
b) 255
c) 1024
d) As many as required
MCQ
• How many data members can a class contain?
a) 27
b) 255
c) 1024
d) As many as required
MCQ
• The this pointer is accessible __________________
a) Within all the member functions of the class
b) Only within functions returning void
c) Only within non-static functions
d) Within the member functions with zero arguments
MCQ
• The this pointer is accessible __________________
a) Within all the member functions of the class
b) Only within functions returning void
c) Only within non-static functions
d) Within the member functions with zero arguments
MCQ
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
MCQ
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
MCQ
• Which rule will not affect the friend function?
a) private and protected members of a class cannot be accessed
from outside
b) private and protected member can be accessed anywhere
c) protected member can be accessed anywhere
d) private member can be accessed anywhere
MCQ
• Which rule will not affect the friend function?
a) private and protected members of a class cannot be
accessed from outside
b) private and protected member can be accessed anywhere
c) protected member can be accessed anywhere
d) private member can be accessed anywhere
MCQ
• Q. Which of the following statement is incorrect?
• A. Constructor is a member function of the class.
• B. The compiler always provides a zero argument constructor.
• C. It is necessary that a constructor in a class should always be
public.
• D. Both B and C.
MCQ
• Q. Which of the following statement is incorrect?
• A. Constructor is a member function of the class.
• B. The compiler always provides a zero argument constructor.
• C. It is necessary that a constructor in a class should always be
public.
• D. Both B and C.