Chapter 6, Exercise 5
Take the file Cartoon.java and comment out the constructor
for the Cartoon class. Explain what happens.
This exercise is not really as meaningful in Scala vs Java
due to the way that I did the Scala translation: I chose
to use the "body-of-the-class" constructor, so it becames pretty
clear that "commenting it out" (it's in red, below) really only means commenting
out the Writeln, and that the compiler still creates a
constructor that initializes the base class.
package x;
class Art { W.rn("Art constructor"); }
class Drawing extends Art { W.rn("Drawing constructor"); }
class Cartoon extends Drawing { W.rn("Cartoon constructor"); }
object c6x5 {
def main ( args: Array[String] ) = {
val powerPuff = new Cartoon;
}
}
9:16:38 PM