1. What is method overloading in OOP?
A. The ability of an object to take on many forms
B. Defining methods with the same name but different parameter types
C. Defining a method in multiple classes with different behavior
D. Reusing a method from a parent class
Answer: B) Defining methods with the same name but different parameter types
Rationale: Method overloading allows defining multiple methods with the same
name but different parameter types or counts.
2. What does the static keyword indicate about a method or variable in OOP?
A. It belongs to an instance of the class
B. It is shared among all instances of the class
C. It cannot be accessed from outside the class
D. It must be overridden in subclasses
Answer: B) It is shared among all instances of the class
,Rationale: A static method or variable is shared across all instances of the class and
can be accessed without creating an instance of the class.
3. Which of the following is an example of a real-world object that can be
represented in an object-oriented system?
A. An integer
B. A car, with properties like color and speed
C. A function that performs calculations
D. A constant value
Answer: B) A car, with properties like color and speed
Rationale: A real-world object like a car can be represented in OOP with attributes
(properties) and methods (behaviors).
4. 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.
5. What does the private access modifier mean in OOP?
A. The member is accessible only within its class
B. The member is accessible from any class
C. The member is accessible from its package only
D. The member is accessible from subclasses
Answer: A) The member is accessible only within its class
Rationale: The private access modifier restricts access to members of a class from
any other class except the class where it is declared.
6. Which of the following can cause an infinite recursion?
A. A constructor calling a parent constructor
B. A method calling itself without a base case
C. A class using multiple inheritance
D. A method overloading with the same name
A. The ability of an object to take on many forms
B. Defining methods with the same name but different parameter types
C. Defining a method in multiple classes with different behavior
D. Reusing a method from a parent class
Answer: B) Defining methods with the same name but different parameter types
Rationale: Method overloading allows defining multiple methods with the same
name but different parameter types or counts.
2. What does the static keyword indicate about a method or variable in OOP?
A. It belongs to an instance of the class
B. It is shared among all instances of the class
C. It cannot be accessed from outside the class
D. It must be overridden in subclasses
Answer: B) It is shared among all instances of the class
,Rationale: A static method or variable is shared across all instances of the class and
can be accessed without creating an instance of the class.
3. Which of the following is an example of a real-world object that can be
represented in an object-oriented system?
A. An integer
B. A car, with properties like color and speed
C. A function that performs calculations
D. A constant value
Answer: B) A car, with properties like color and speed
Rationale: A real-world object like a car can be represented in OOP with attributes
(properties) and methods (behaviors).
4. 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.
5. What does the private access modifier mean in OOP?
A. The member is accessible only within its class
B. The member is accessible from any class
C. The member is accessible from its package only
D. The member is accessible from subclasses
Answer: A) The member is accessible only within its class
Rationale: The private access modifier restricts access to members of a class from
any other class except the class where it is declared.
6. Which of the following can cause an infinite recursion?
A. A constructor calling a parent constructor
B. A method calling itself without a base case
C. A class using multiple inheritance
D. A method overloading with the same name