Overloading a method means defining multiple methods in the same class, each with the same name , each of which accepts a different parameter list. In this example the Vehicle class extends the Car class. Let us assume that by default, the honk() method will make a honking sound one time.
class Car extends Vehicle { void honk() { // honk code goes here } void honk(int numberOfHonks) { // honk int number of times } }
Top |