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