0% found this document useful (0 votes)
10 views15 pages

MCQ4

The document contains multiple-choice questions (MCQs) related to C++ programming concepts, including class declarations, features of object-oriented programming, data members, the 'this' pointer, friend functions, and constructors. Each question presents options for the correct answer, focusing on fundamental principles of C++. The content is structured in a quiz format, aimed at testing knowledge of C++ programming.

Uploaded by

pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views15 pages

MCQ4

The document contains multiple-choice questions (MCQs) related to C++ programming concepts, including class declarations, features of object-oriented programming, data members, the 'this' pointer, friend functions, and constructors. Each question presents options for the correct answer, focusing on fundamental principles of C++. The content is structured in a quiz format, aimed at testing knowledge of C++ programming.

Uploaded by

pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

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.

You might also like