Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q111: What is the primary purpose of member functions in a class?
- A: To model the behaviors of an object
- B: To store data values
- C: To initialize class objects
- D: To define class attributes
View Answer
A
Q112: Which of the following access specifiers allows access to class members only through member functions?
- A: private
- B: public
- C: protected
- D: private
View Answer
A
Q113: Fill in the blank: When no access specifier is mentioned in a C++ class, the default access specifier is _______.
- A: private
- B: public
- C: protected
- D: static
View Answer
A
Q114: In the context of object-oriented programming, abstraction involves _______.
- A: including all details in the system
- B: including only relevant details for the system
- C: ignoring object attributes
- D: removing object behavior
View Answer
B
Q115: Which of the following is not a valid access specifier in C++?
- A: hidden
- B: protected
- C: public
- D: private
View Answer
B
Q116: Fill in the blank: In C++, the dot operator (.) is used to access members of an object via a _______.
- A: pointer
- B: object
- C: reference
- D: method
View Answer
B
Q117: Fill in the blank: The arrow operator (->) is used to access members of a class through a _______.
- A: student
- B: object
- C: pointer
- D: relationship
View Answer
C
Q118: When defining a class in C++, which of the following is not required?
- A: Constructor
- B: Destructor
- C: Member functions
- D: Access specifier
View Answer
D
Q119: Which of the following statements about a class constructor in C++ is true?
- A: A constructor initializes data members of a class.
- B: A constructor is used to define class attributes.
- C: A constructor is used to declare objects of a class.
- D: A constructor is used to destroy objects of a class.
View Answer
A
Q120: The class keyword in C++ is used to define _______.
- A: a user-defined type
- B: a primitive data type
- C: a built-in data type
- D: a function
View Answer
B