Bird
0
0

Which of the following method signatures correctly overrides this method?

easy📝 Syntax Q3 of 15
Java - Polymorphism
Which of the following method signatures correctly overrides this method?
protected Object process(String input)
Aprivate Object process(String input)
Bprotected String process(String input)
Cprotected Object process(String input)
Dprotected Object process(Object input)
Step-by-Step Solution
Solution:
  1. Step 1: Check method name and parameters

    The overriding method must have the exact same name and parameter list.
  2. Step 2: Check return type

    The return type must be the same or a subtype (covariant return allowed). Here, return type is Object, so it must be Object or subclass.
  3. Step 3: Check access modifier

    Access modifier can be the same or more accessible. 'protected' is allowed.
  4. Final Answer:

    protected Object process(String input) -> Option C
  5. Quick Check:

    Signature and access match exactly [OK]
Quick Trick: Exact signature and compatible return type required [OK]
Common Mistakes:
  • Changing parameter types breaks overriding
  • Using more restrictive access modifier is invalid
  • Return type must be compatible or covariant

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes