In object-oriented programming, what mechanism allows a subclass to provide a specific implementation of a method already defined in its superclass?

Answer and explanation

Correct answer: C. Method overriding

  1. Step 1: Method overriding occurs when a subclass re-implements a method with the exact same name, return type, and parameters as in the superclass.
  2. Step 2: It enables dynamic runtime polymorphism (virtual method dispatch).
Answer
Method overriding.
Why not the others: 'Method overloading' defines multiple methods with the same name but different signatures within the same class; 'Data encapsulation' hides private state; 'Multiple instantiation' creates multiple objects.

Practise more Python Programming, Data Structures, Algorithms, Networks and Cybersecurity.

Free questions with an explanation for every one, and full timed Saudi Secondary School Certificate mock tests.