Inheritance is an object oriented concept which is used to reusability of code. You can achieve inheritance by using extends keyword. To achieve inheritance a class must extend to other class. A class which is extended called super or parent class. a class which extends class is called derived or base class.Syntax
Understand the Simple Example of Inheritance
Scala Single Inheritance Example
Salary = 10000.0 Bonus = 5000
Types of Inheritance in Scala
Scala supports various types of inheritance including single, multilevel, multiple, and hybrid. You can use single, multilevel and hierarchal in your class. Multiple and hybrid can only be achieved by using traits. Here, we are representing all types of inheritance by using pictorial form.
Scala Multilevel Inheritance Example
salary1 = 10000 salary2 = 20000