Final answer:
When a subclass inherits a method from its superclass, there are four things we can choose to do in the subclass: override the method with a new implementation, add additional functionality to the inherited method, call the superclass method and add additional functionality, or do nothing and use the inherited method as is.
Step-by-step explanation:
When a subclass inherits a method from its superclass, there are four things we can choose to do in the subclass:
- Override the method with a new implementation: In this case, the subclass provides its own implementation of the method, which replaces the implementation inherited from the superclass.
- Add additional functionality to the inherited method: Here, the subclass extends the functionality of the inherited method by adding new instructions or logic to it, while still using the superclass's implementation.
- Call the superclass method and add additional functionality: This involves invoking the superclass's implementation of the method using the super keyword, and then adding additional instructions or logic to it.
- Do nothing and use the inherited method as is: If the subclass does not override or extend the method, it will use the inherited method as is, without any modifications.