1. What does the super keyword refer to in object-oriented programming?
A. A reference to the parent class
B. A reference to the current object
C. A reference to the method in the current class
D. A reference to the method in the derived class
Answer: A) A reference to the parent class
Rationale: The super keyword is used to refer to the parent class, typically to call a
method or constructor of the parent class.
2. Which of the following is a valid reason to use interfaces in OOP?
A. To provide a concrete implementation of methods
B. To define a contract that classes must follow
C. To allow inheritance of properties
D. To provide access to the instance variables of other classes
Answer: B) To define a contract that classes must follow
,Rationale: An interface defines a set of methods that any implementing class must
provide, promoting a contract-based approach.
3. What is the purpose of a getter method in OOP?
A. To change the value of a property
B. To return the value of a property
C. To destroy an object
D. To display the object's state
Answer: B) To return the value of a property
Rationale: A getter method is used to access the value of an object's property,
especially when the property is private.
4. Which of the following is true about abstract methods in OOP?
A. They must be defined in the base class
B. They must have a body in the base class
C. They are not meant to be directly called
D. They cannot have parameters
Answer: C) They are not meant to be directly called
, Rationale: Abstract methods provide a template for subclasses to implement but
cannot be called directly as they have no body.
5. Which of the following is the correct definition of abstraction in OOP?
A. Hiding data and methods from external access
B. Defining the interface and leaving the implementation to the derived class
C. Reusing code from multiple classes
D. Overloading methods in the same class
Answer: B) Defining the interface and leaving the implementation to the derived
class
Rationale: Abstraction hides the complex implementation details and exposes only
the necessary parts of an object or class through a simplified interface.
6. What is multiple inheritance in OOP?
A. When a class inherits from multiple base classes
B. When a class has multiple constructors
C. When an object is inherited by multiple classes
D. When a method can take many forms
A. A reference to the parent class
B. A reference to the current object
C. A reference to the method in the current class
D. A reference to the method in the derived class
Answer: A) A reference to the parent class
Rationale: The super keyword is used to refer to the parent class, typically to call a
method or constructor of the parent class.
2. Which of the following is a valid reason to use interfaces in OOP?
A. To provide a concrete implementation of methods
B. To define a contract that classes must follow
C. To allow inheritance of properties
D. To provide access to the instance variables of other classes
Answer: B) To define a contract that classes must follow
,Rationale: An interface defines a set of methods that any implementing class must
provide, promoting a contract-based approach.
3. What is the purpose of a getter method in OOP?
A. To change the value of a property
B. To return the value of a property
C. To destroy an object
D. To display the object's state
Answer: B) To return the value of a property
Rationale: A getter method is used to access the value of an object's property,
especially when the property is private.
4. Which of the following is true about abstract methods in OOP?
A. They must be defined in the base class
B. They must have a body in the base class
C. They are not meant to be directly called
D. They cannot have parameters
Answer: C) They are not meant to be directly called
, Rationale: Abstract methods provide a template for subclasses to implement but
cannot be called directly as they have no body.
5. Which of the following is the correct definition of abstraction in OOP?
A. Hiding data and methods from external access
B. Defining the interface and leaving the implementation to the derived class
C. Reusing code from multiple classes
D. Overloading methods in the same class
Answer: B) Defining the interface and leaving the implementation to the derived
class
Rationale: Abstraction hides the complex implementation details and exposes only
the necessary parts of an object or class through a simplified interface.
6. What is multiple inheritance in OOP?
A. When a class inherits from multiple base classes
B. When a class has multiple constructors
C. When an object is inherited by multiple classes
D. When a method can take many forms