// INHERIT17_toString

// Since every class in Java is a subclass of class $Object$, you may
// use methods inherited from $Object$.

// One such method, $toString$, provides a good way of returning a string
// representation of the object. If you print the inherited version
// from $Object$, you will see the object's address. Note that
// printing an object's reference causes Java to automatically call
// that object's $toString$ method.

public class inherit17_toString {
    public static void main(String[] args) {
	A a = new A();	
	System.out.println("Print using overridden $toString$: "+ a);	
	System.out.println("Print using default $toString$:    "+a.test());
    }
}

class A {
    public String test() {return super.toString(); }
    public String toString() { return "hi!"; }
}

/* Output:
   Print using overridden $toString$: hi!
   Print using default $toString$:    A@b46533e5
*/
