GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Monday 19 July 2004
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   comment/     


Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/2/6; 12:41:25 .
Click here to send an email to the editor of this weblog.

July 2004
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Jun   Aug

Previous/Next