Javatpoint Logo
Javatpoint Logo

Scala Method Overriding

When a subclass has the same name method as defined in the parent class, it is known as method overriding. When subclass wants to provide a specific implementation for the method defined in the parent class, it overrides method from parent class.

In scala, you must use either override keyword or override annotation to override methods from parent class.

Scala Method Overriding Example 1


Bike is running

Real example of method overriding


Scala Inheritance 3

Scala Method Overriding Example 2

This example shows how subclasses override the method of parent class.


SBI Rate of Interest: 8
ICICI Rate of Interest: 7
AXIS Rate of Interest: 9

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA