class Father{
String name;
public Father(){
name="father";
}
public String getName() {
show();
return name;
}
public void show() {
System.out.println("father's show...");
}
}
public class Son extends Father{
public static void main(String[] args) {
Father f=new Son();
System.out.println(f.getName());
}
public void show() {
System.out.println("son's show...");
}
}
运行结果:
Son's show...
father