
In ECET 2026 CSE, Java OOPs concepts like method overriding and dynamic method dispatch are frequently asked. These topics test understanding of polymorphism and runtime behavior of objects.
📘 Concept Notes
🔹 What is Method Overriding?
- Method overriding occurs when a subclass provides its own implementation of a method that is already defined in its superclass.
- Rules:
- Method name, parameters, and return type must be the same.
- Access level cannot be more restrictive.
- Only inherited (non-private) methods can be overridden.
- Annotated using
@Override
for clarity.
Example:
class Parent {
void display() {
System.out.println("Parent class method");
}
}
class Child extends Parent {
@Override
void display() {
System.out.println("Child class method");
}
}
public class Test {
public static void main(String[] args) {
Child obj = new Child();
obj.display(); // Output: Child class method
}
}
🔹 What is Dynamic Method Dispatch?
- Also known as runtime polymorphism.
- It is the process where a method call is resolved at runtime instead of compile-time.
- Happens when a superclass reference variable refers to a subclass object.
Example:
class Animal {
void sound() {
System.out.println("Animal makes sound");
}
}
class Dog extends Animal {
@Override
void sound() {
System.out.println("Dog barks");
}
}
class Cat extends Animal {
@Override
void sound() {
System.out.println("Cat meows");
}
}
public class DispatchDemo {
public static void main(String[] args) {
Animal ref; // Reference of superclass
ref = new Dog();
ref.sound(); // Output: Dog barks
ref = new Cat();
ref.sound(); // Output: Cat meows
}
}
⚙️ Formula (Polymorphism Conceptual Expression)
This means → Actual method execution depends on object type not reference type.
🔟 10 Expected MCQs – ECET 2026
Q1. Method overriding means:
A) Same method name with different parameters
B) Redefining method of superclass in subclass
C) Defining static methods only
D) Using private methods in subclass
Q2. Dynamic method dispatch is also called:
A) Compile-time polymorphism
B) Runtime polymorphism
C) Method overloading
D) Encapsulation
Q3. Which keyword is commonly used while overriding?
A) @Super
B) @Override
C) @Overload
D) @Dynamic
Q4. Which access modifier cannot be overridden?
A) protected
B) public
C) private
D) default
Q5. In dynamic method dispatch, the method executed depends on:
A) Reference type
B) Object type
C) Both reference and object type
D) Compiler
Q6. Can constructors be overridden in Java?
A) Yes
B) No
C) Only if public
D) Only in abstract class
Q7. Which of the following is correct?
A) Static methods can be overridden
B) Final methods can be overridden
C) Private methods can be overridden
D) Instance methods can be overridden
Q8. If superclass has a method show()
and subclass overrides it, calling show()
with subclass object will call:
A) Superclass method
B) Subclass method
C) Both methods
D) Compilation error
Q9. Which of these is an example of dynamic dispatch?
A) Method overloading
B) Method overriding
C) Constructor chaining
D) Static binding
Q10. In method overriding, return type must be:
A) Always void
B) Same or covariant
C) Different always
D) Any type
✅ Answer Key
Q.No | Answer |
---|---|
Q1 | B |
Q2 | B |
Q3 | B |
Q4 | C |
Q5 | B |
Q6 | B |
Q7 | D |
Q8 | B |
Q9 | B |
Q10 | B |
🧠 Explanations
- Q1 → B: Overriding = redefining superclass method in subclass.
- Q2 → B: Dynamic method dispatch = runtime polymorphism.
- Q3 → B:
@Override
ensures method is overridden correctly. - Q4 → C: Private methods are not inherited → cannot override.
- Q5 → B: Method executed depends on object type.
- Q6 → B: Constructors cannot be overridden.
- Q7 → D: Only instance methods are overridden.
- Q8 → B: Subclass method executes.
- Q9 → B: Overriding is runtime polymorphism.
- Q10 → B: Return type must be same or covariant.
🎯 Why Practice Matters
- Java OOPs questions appear every year in ECET.
- Method overriding + dynamic dispatch = guaranteed questions.
- Understanding them helps in both exams and interview coding rounds.