Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Chapter: 6
Q101:
The Menu class in the model has which attribute?
A. Name
B. Color
C. Vertices
D. Length
Correct Answer: A
Chapter: 6
Q102:
Fill in the blank: The Shape class has the following operations: draw, select, move, and _______.
A. rotate
B. add
C. remove
D. group
Correct Answer: D
Chapter: 6
Q103:
Fill in the blank: The View class in the graphic editor model can _______ shapes.
A. Add
B. Remove
C. Select
D. All of the above
Correct Answer: D
Chapter: 6
Q104:
The Group class inherits attributes from:
A. The Shape class
B. The Menu class
C. The Line class
D. The View class
Correct Answer: A
Chapter: 7
Q105:
In C++, a class is used to _______.
A. define a new data type
B. calculate mathematical operations
C. handle file input/output
D. manage system resources
Correct Answer: A
Chapter: 7
Q106:
Which of the following is true about classes in C++?
A. A class can be defined to include both data members and methods.
B. A class cannot include methods.
C. A class only includes methods, not data members.
D. A class can only be used to define primitive data types.
Correct Answer: A
Chapter: 7
Q107:
An object in C++ is an _______ of a class.
A. instance
B. attribute
C. method
D. operation
Correct Answer: A
Chapter: 7
Q108:
When defining a class, the keyword 'public' means that members are _______.
A. accessible only within the class
B. accessible from outside the class
C. accessible only by friend classes
D. accessible only by derived classes
Correct Answer: B
Chapter: 7
Q109:
In C++, the default access specifier for class members is _______.
A. private
B. protected
C. public
D. none
Correct Answer: A
Chapter: 7
Q110:
To access members of a class through a pointer, which operator is used?
A. .
B. ->
C. ::
D. &
Correct Answer: B
Chapter: 7
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
Correct Answer: A
Chapter: 7
Q112:
Which of the following access specifiers allows access to class members only through member functions?
A. private
B. public
C. protected
D. private
Correct Answer: A
Chapter: 7
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
Correct Answer: A
Chapter: 7
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
Correct Answer: B
Chapter: 7
Q115:
Which of the following is not a valid access specifier in C++?
A. hidden
B. protected
C. public
D. private
Correct Answer: B
Chapter: 7
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
Correct Answer: B
Chapter: 7
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
Correct Answer: C
Chapter: 7
Q118:
When defining a class in C++, which of the following is not required?
A. Constructor
B. Destructor
C. Member functions
D. Access specifier
Correct Answer: D
Chapter: 7
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.
Correct Answer: A
Chapter: 7
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
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now