Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A programmer notices that a method of a subclass has the same signature as a met

ID: 3839931 • Letter: A

Question

A programmer notices that a method of a subclass has the same signature as a method in its superclass. Which of the following statements best characterizes this situation? Why? a. The superclass method is overloaded. b. The superclass method shadows the subclass method. c. The subclass method overrides the superclass method. d. The superclass method overrides the subclass method. e. The program will not compile because methods of two classes in the same inheritance hierarchy cannot have the same name.

Explanation / Answer

c. The subclass method overrides the superclass method.

The reason is that subclass extends the superclass and now it has all the methods of superclass. But now if we create a method with same name as that of a methoad in superclass, it will override it. This is the property of Polymorphism in Method Overriding.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote