Chapter 6, Exercise 1
Create two classes, A and B, with default constructors (empty
argument lists) that announce themselves. Create a new class
called C that inherits from A, and create a member of class B
inside C. Do not create a constructor for C. Create an object
of class C and observe the results.
package x;
class A { W.rn( "A constructor called" ); }
class B { W.rn( "B constructor called" ); }
class C extends A { val obj_b = new B(); }
object c6x1 {
def main ( args : Array[String] ) = {
val obj_c = new C();
}
}
Output
A constructor called
B constructor called
7:36:45 AM