146k views
0 votes
Which of the following is true about an abstract method inherited into a class called C?

A. It must be defined in C before C can be instantiated
B. It must be overridden in C before C can be instantiated
C. It always forces C to become abstract
D. It overrides any method in C with the same name

User Colinjwebb
by
8.2k points

1 Answer

4 votes

Final answer:

In object-oriented programming, an abstract method must be overridden in the class that inherits it before an object of that class can be instantiated.

Step-by-step explanation:

In object-oriented programming, an abstract method is a method that is declared in an abstract class but does not have an implementation. When a class called C inherits an abstract method from its superclass, there are certain rules that apply:

  1. Option A: It must be defined in C before C can be instantiated - This is incorrect. While the abstract method must be implemented in a concrete class before it can be instantiated, it does not necessarily need to be defined in the class itself.
  2. Option B: It must be overridden in C before C can be instantiated - This is correct. An abstract method must be overridden (implemented) in the class that inherits it before an object of that class can be instantiated.
  3. Option C: It always forces C to become abstract - This is incorrect. The class C is not forced to become abstract when it inherits an abstract method. It can still be a concrete class as long as it overrides the abstract method.
  4. Option D: It overrides any method in C with the same name - This is incorrect. Inheritance of an abstract method does not automatically override any method with the same name in the inheriting class. The method in the inheriting class must explicitly override the abstract method.

Therefore, the correct answer is Option B: It must be overridden in C before C can be instantiated.

User JamesKn
by
8.2k points