Scala features a lot of object-oriented functionality. This means it supports inheritance concepts that are core to the object-oriented programming. Moreover, since Scala compiles to the Java Virtual Machine, it is essential that it supports the same model as Java for Java interoperability reasons.
Inheritance model
Classes
Classes in Scala have similar semantics to their Java counterparts. They are defined as follows:
scala> :paste
// Entering paste mode (ctrl-D to finish)
class Dummy(constructorArgument: String) {
var variable: Int = 0
val value: String = constructorArgument * 2
def method(x: Int): String = s"You gave me $x"
}
// Exiting paste mode, now interpreting.
defined class Dummy
scala> new Dummy("...