draw depends on the actual type of the object that s refers to not on the type

Draw depends on the actual type of the object that s

This preview shows page 16 - 22 out of 26 pages.

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 s.draw(); int t = s.i; int k= s.j;//?? s.erase(); //??? s.setColor(); Shape i: int draw() setColor() Circle i: int j:int draw() erase() Triangle i: int draw() erase() Line i: int draw() erase()
Image of page 16