CS217 Object Oriented Programming
Midterm Exam Review (Qns & Ans)
2025
1. Which principle of Object-Oriented Programming ensures that
an object’s internal details are hidden from external access?
A. Polymorphism
B. Inheritance
C. Encapsulation
D. Abstraction
ANS: C. Encapsulation
Rationale: Encapsulation restricts access to an object’s internal
state, exposing only necessary functionality.
2. Which of the following describes polymorphism in OOP?
©2025
, A. Reusing code in derived classes
B. Implementing multiple methods with the same name but
different behaviors
C. Restricting object instantiation to a single instance
D. Combining multiple classes into a single object
ANS: B. Implementing multiple methods with the same
name but different behaviors
Rationale: Polymorphism enables code flexibility by allowing
a method to adapt its behavior based on its context.
3. In OOP, what is the purpose of an abstract class?
A. Creating objects directly
B. Preventing inheritance
C. Providing a base class with incomplete functionality for
subclasses to implement
D. Eliminating redundant methods
ANS: C. Providing a base class with incomplete functionality
for subclasses to implement
Rationale: Abstract classes act as templates for derived classes,
specifying methods without complete implementations.
4. Which of the following is an example of multiple inheritance?
©2025
, A. A subclass inheriting from a single parent class
B. A class inheriting properties and methods from more than
one parent class
C. An object containing multiple data attributes
D. A superclass overriding its subclass’s methods
ANS: B. A class inheriting properties and methods from
more than one parent class
Rationale: Multiple inheritance allows a class to derive
functionality from multiple parent classes.
5. What does the term "method overriding" refer to in OOP?
A. Replacing a method in a parent class with a new
implementation in a subclass
B. Defining two methods with identical signatures in the same
class
C. Hiding private methods from external access
D. Assigning default values to method arguments
ANS: A. Replacing a method in a parent class with a new
implementation in a subclass
Rationale: Method overriding enables subclass-specific
behavior by redefining a parent class method.
---
©2025
, Fill-in-the-Blank Questions
6. In object-oriented programming, ________ refers to
combining multiple data attributes and methods into a single
entity.
ANS: Class
Rationale: Classes group related attributes and methods into
one logical structure.
7. The keyword ________ is used in many OOP languages to
create an instance of a class.
ANS: new
Rationale: The `new` keyword is commonly used to instantiate
objects in languages like Java and C++.
8. The process of defining methods in a subclass with the same
name as those in the parent class is known as ________.
ANS: Overriding
Rationale: Overriding allows subclasses to provide specific
implementations for inherited methods.
9. A ________ is a special type of method used to initialize
objects of a class.
©2025
Midterm Exam Review (Qns & Ans)
2025
1. Which principle of Object-Oriented Programming ensures that
an object’s internal details are hidden from external access?
A. Polymorphism
B. Inheritance
C. Encapsulation
D. Abstraction
ANS: C. Encapsulation
Rationale: Encapsulation restricts access to an object’s internal
state, exposing only necessary functionality.
2. Which of the following describes polymorphism in OOP?
©2025
, A. Reusing code in derived classes
B. Implementing multiple methods with the same name but
different behaviors
C. Restricting object instantiation to a single instance
D. Combining multiple classes into a single object
ANS: B. Implementing multiple methods with the same
name but different behaviors
Rationale: Polymorphism enables code flexibility by allowing
a method to adapt its behavior based on its context.
3. In OOP, what is the purpose of an abstract class?
A. Creating objects directly
B. Preventing inheritance
C. Providing a base class with incomplete functionality for
subclasses to implement
D. Eliminating redundant methods
ANS: C. Providing a base class with incomplete functionality
for subclasses to implement
Rationale: Abstract classes act as templates for derived classes,
specifying methods without complete implementations.
4. Which of the following is an example of multiple inheritance?
©2025
, A. A subclass inheriting from a single parent class
B. A class inheriting properties and methods from more than
one parent class
C. An object containing multiple data attributes
D. A superclass overriding its subclass’s methods
ANS: B. A class inheriting properties and methods from
more than one parent class
Rationale: Multiple inheritance allows a class to derive
functionality from multiple parent classes.
5. What does the term "method overriding" refer to in OOP?
A. Replacing a method in a parent class with a new
implementation in a subclass
B. Defining two methods with identical signatures in the same
class
C. Hiding private methods from external access
D. Assigning default values to method arguments
ANS: A. Replacing a method in a parent class with a new
implementation in a subclass
Rationale: Method overriding enables subclass-specific
behavior by redefining a parent class method.
---
©2025
, Fill-in-the-Blank Questions
6. In object-oriented programming, ________ refers to
combining multiple data attributes and methods into a single
entity.
ANS: Class
Rationale: Classes group related attributes and methods into
one logical structure.
7. The keyword ________ is used in many OOP languages to
create an instance of a class.
ANS: new
Rationale: The `new` keyword is commonly used to instantiate
objects in languages like Java and C++.
8. The process of defining methods in a subclass with the same
name as those in the parent class is known as ________.
ANS: Overriding
Rationale: Overriding allows subclasses to provide specific
implementations for inherited methods.
9. A ________ is a special type of method used to initialize
objects of a class.
©2025