Bird
0
0

Which of the following is allowed when overriding a method in Java?

easy📝 Conceptual Q1 of 15
Java - Polymorphism
Which of the following is allowed when overriding a method in Java?
AChanging the method name
BMaking the method static
CChanging the number of parameters
DChanging the return type to a subtype of the original return type
Step-by-Step Solution
Solution:
  1. Step 1: Understand method overriding rules

    Method overriding requires the same method name and parameters. Return type can be a subtype (covariant return type).
  2. Step 2: Analyze each option

    Changing method name or parameters means overloading, not overriding. Static methods cannot be overridden.
  3. Final Answer:

    Changing the return type to a subtype of the original return type -> Option D
  4. Quick Check:

    Method overriding allows covariant return types = B [OK]
Quick Trick: Override must keep name and parameters; return type can be subtype [OK]
Common Mistakes:
  • Thinking method name can change
  • Confusing overriding with overloading
  • Trying to override static methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes