zuai-logo

Overriding Methods

Caleb Thomas

Caleb Thomas

3 min read

Listen to this study note

Study Guide Overview

This study guide covers subclass methods, including inheritance of public methods. It focuses on method overriding and overloading, explaining their differences and implementation. The guide uses a Rectangle class example to demonstrate method overriding with the @Override annotation and discusses adding new instance variables and methods in subclasses.

Now that we know how to make subclasses and their constructors, it is time to write their methods. A subclass will inherit all public methods from the superclass. These methods will remain public in the subclass. Most methods that are inherited from the superclass do not need to be rewritten.

Any method that we call on an object must be defined within the class associated with that object or within th...

Question 1 of 7

🎉 A subclass automatically gets access to which type of methods from its superclass?

Private methods

Protected methods

Public methods

Static methods