July 2017
Intermediate to advanced
796 pages
18h 55m
English
An abstract class in Scala can have constructor parameters as well as type parameters. An abstract class in Scala is fully interoperable with Java. In other words, it is possible to call them from Java code without any intermediate wrappers.
So, what is the difference between an abstract class and the traits in Scala? As you have seen, an abstract class can have constructor parameters, type parameters, and multiple parameters. However, a trait in Scala can have only type parameters. The following is a simple example of an abstract class:
abstract class Animal(animalName:String = "notset") { //Method with definition/return type def getAnimalAge //Method with no definition with String return type def getAnimalGender : String ...Read now
Unlock full access