If we have overloaded constructors we can access other constructors from within

If we have overloaded constructors we can access

This preview shows page 7 - 11 out of 11 pages.

:
Image of page 7
Image of page 8
What is the output of the following program? class Test { String message = "Global"; public static void A( String message) { message = message + "End"; } public static void main( String args[] ) { String message = "Main"; A( message ); System.out.println( message ); } }
Image of page 9
Polymorphism with methods/instance variable When you call one of the parent class methods draw() (that have been overridden in the child classes), the method executed by s .draw() depends on the actual type of the object that s refers to, not on the type of the variable s. Overridden variable depends on the type of variable of s Shape s = new Circle(); System.out.println(s.getClass()); // class Circle Shape i: int draw() setColor() Circle i: int
Image of page 10
Image of page 11

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture