/** * This code is from the book: * Winder, R and Roberts, G (1998) * Developing Java Software</em> * John Wiley & Sons. * It is copyright (c) 1997 Russel Winder * and Graham Roberts. */ class Superclass{ public void f(int x){ System.out.println("Superclass int" + x); } } class Subclass extends Superclass{ public void h(int x, double y, double z){ System.out.println("Subclass int int double "); } public void h(double x, double y, double z) {} public void g(int x, double y) {} public void g(double x, int y) {} public void f(double d){ System.out.println("Subclass double " + d); } public void f(String s){ System.out.println("Subclass: " + s); } public void k(int x){ f(1.0); } public static void k(double x) {} } public class l1Inherit4{//Inherit3 public static void main(String[] args){ Superclass superclass = new Superclass(); superclass.f(10); Subclass subclass = new Subclass(); //subclass.f(10); subclass.f(1.1); subclass.k(1.0); subclass.g(1.0,1); //subclass.g(1,1); subclass.g(1,1.0); subclass.h(1,1,1); superclass = subclass; // superclass.f(10.1); } } /******** sample compilation & run ******** # javac l1Inherit4.java # java l1Inherit4 Superclass int10 Subclass double 1.1 Subclass int int double # ******************************************/