Question: Question: How does Java handle method overriding when a subclass provides a method with the same name and parameters as a method in its superclass?
Question: How does Java handle method overriding when a subclass provides a method with the same name and parameters as a method in its superclass?
A) The subclass method automatically overrides the superclass method and inherits all its functionality.
B) The subclass method does not override the superclass method unless it is explicitly marked with the @Override annotation.
C) The subclass method creates a new method, and the superclass method remains unaffected and callable through the subclass.
D) The subclass method throws a compilation error if it has the same name and parameters as the superclass method.
Step by Step Solution
There are 3 Steps involved in it
The detailed answer for the above question is provided below The correct option is B The subclass method does not override the superclass method unles... View full answer
Get step-by-step solutions from verified subject matter experts
