IS 128
Object-Oriented Programming I
Midterms Exam Review (Qns & Ans)
2025
1. Which of the following is a key benefit of encapsulation in
object-oriented programming?
A. Allows direct access to class fields
B. Hides implementation details and protects object state
C. Improves data storage efficiency
D. Enables the creation of abstract classes
- ANS: B. Hides implementation details and protects object
state
- Rationale: Encapsulation restricts direct access to object
fields, ensuring controlled interaction through methods.
©2025
,2. What is the primary purpose of polymorphism in OOP?
A. To reduce memory consumption
B. To allow a single interface to represent different data types or
classes
C. To simplify debugging processes
D. To store objects in arrays
- ANS: B. To allow a single interface to represent different
data types or classes
- Rationale: Polymorphism enables code flexibility by
allowing a single method or interface to work with different types
of objects.
3. In object-oriented programming, what is the term for creating
a new class based on an existing class?
A. Encapsulation
B. Composition
C. Inheritance
D. Abstraction
- ANS: C. Inheritance
- Rationale: Inheritance allows a new class (child) to acquire
properties and behaviors of an existing class (parent).
©2025
,4. Which of the following defines an abstract class?
A. A class with only static methods
B. A class that cannot be instantiated and includes at least one
abstract method
C. A class with private fields only
D. A class that implements an interface
- ANS: B. A class that cannot be instantiated and includes at
least one abstract method
- Rationale: Abstract classes serve as blueprints for other
classes and cannot be instantiated directly.
5. What does the "this" keyword refer to in object-oriented
programming?
A. The parent class
B. The current instance of the class
C. A static class variable
D. An unrelated object
- ANS: B. The current instance of the class
- Rationale: The "this" keyword is used to refer to the current
object within a method or constructor.
©2025
, ---
Fill-in-the-Blank Questions
6. __________ is the principle that allows a derived class to
override a method in its base class with a new implementation.
- ANS: Method Overriding
- Rationale: Method overriding occurs when a subclass
provides its own implementation for a method defined in its
parent class.
7. In OOP, __________ is a design pattern that ensures a class
has only one instance and provides a global access point to it.
- ANS: Singleton
- Rationale: The Singleton pattern restricts a class to a single
instance, often used in resource management.
8. The __________ relationship in object-oriented programming
is characterized by "is-a" hierarchy, such as a car being a type of
vehicle.
- ANS: Inheritance
- Rationale: The "is-a" relationship defines inheritance,
where a subclass inherits properties and behaviors from a
superclass.
©2025
Object-Oriented Programming I
Midterms Exam Review (Qns & Ans)
2025
1. Which of the following is a key benefit of encapsulation in
object-oriented programming?
A. Allows direct access to class fields
B. Hides implementation details and protects object state
C. Improves data storage efficiency
D. Enables the creation of abstract classes
- ANS: B. Hides implementation details and protects object
state
- Rationale: Encapsulation restricts direct access to object
fields, ensuring controlled interaction through methods.
©2025
,2. What is the primary purpose of polymorphism in OOP?
A. To reduce memory consumption
B. To allow a single interface to represent different data types or
classes
C. To simplify debugging processes
D. To store objects in arrays
- ANS: B. To allow a single interface to represent different
data types or classes
- Rationale: Polymorphism enables code flexibility by
allowing a single method or interface to work with different types
of objects.
3. In object-oriented programming, what is the term for creating
a new class based on an existing class?
A. Encapsulation
B. Composition
C. Inheritance
D. Abstraction
- ANS: C. Inheritance
- Rationale: Inheritance allows a new class (child) to acquire
properties and behaviors of an existing class (parent).
©2025
,4. Which of the following defines an abstract class?
A. A class with only static methods
B. A class that cannot be instantiated and includes at least one
abstract method
C. A class with private fields only
D. A class that implements an interface
- ANS: B. A class that cannot be instantiated and includes at
least one abstract method
- Rationale: Abstract classes serve as blueprints for other
classes and cannot be instantiated directly.
5. What does the "this" keyword refer to in object-oriented
programming?
A. The parent class
B. The current instance of the class
C. A static class variable
D. An unrelated object
- ANS: B. The current instance of the class
- Rationale: The "this" keyword is used to refer to the current
object within a method or constructor.
©2025
, ---
Fill-in-the-Blank Questions
6. __________ is the principle that allows a derived class to
override a method in its base class with a new implementation.
- ANS: Method Overriding
- Rationale: Method overriding occurs when a subclass
provides its own implementation for a method defined in its
parent class.
7. In OOP, __________ is a design pattern that ensures a class
has only one instance and provides a global access point to it.
- ANS: Singleton
- Rationale: The Singleton pattern restricts a class to a single
instance, often used in resource management.
8. The __________ relationship in object-oriented programming
is characterized by "is-a" hierarchy, such as a car being a type of
vehicle.
- ANS: Inheritance
- Rationale: The "is-a" relationship defines inheritance,
where a subclass inherits properties and behaviors from a
superclass.
©2025