July 2017
Intermediate to advanced
796 pages
18h 55m
English
If you want to override a concrete method from the superclass, the override modifier is necessary. However, if you are implementing an abstract method, it is not strictly necessary to add the override modifier. Scala uses the override keyword to override a method from a parent class. For example, suppose you have the following abstract class and a method printContents() to print your message on the console:
abstract class MyWriter { var message: String = "null" def setMessage(message: String):Unit def printMessage():Unit}
Now, add a concrete implementation of the preceding abstract class to print the contents on the console as follows:
class ConsolePrinter extends MyWriter { def setMessage(contents: ...Read now
Unlock full access