GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Wednesday 19 May 2004
Chapter 4, Exercises 8-9

Exercise 8 directs us "Create a class without a constructor, and then create an object of that class in main() to verify that the default constructor is automatically synthesized." My response was "Haven't we been doing that already for 5 or 6 exercises?" Then I went to look at the Clapp's version of 4.8, and s/he had written "I've skipped 4.8. It looks pretty trivial."

For completeness, anyway:

Chapter 4, Exercise 8

class c4x8c { Console.println( "A c4x8c object" ) };
object c4x8 {
    def main ( args: Array[String] ) = {
        val obj = new c4x8c;
    }
}

Chapter 4, Exercise 9

class c4x9c {
    def meth1 = {
        meth2( "meth2" );
        this.meth2( "this.meth2" );
    }
    def meth2( s: String ) = {
        Console.println( "Meth2 called as " + s );
    }
}
object c4x9 {
    def main ( args: Array[String] ) = {
        val obj = new c4x9c;
        obj.meth1;
    }
}

11:36:40 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:39:35 .
Click here to send an email to the editor of this weblog.

May 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          
Apr   Jun

Previous/Next