public class Son extends Father {
private String name = "son";
public Son () {
tellName();
printName();
}
public void tellName() {
System.out.println("Son tell name: " + name);
}
public void printName() {
System.out.println("Son print name: " + name);
}
public static void main(String[] args){
new Son ();
}
}
class Father{
private String name = "father";
public Father() {
tellName();
printName();
}
public void tellName() {
System.out.println("Fathertell name: " + name);
}
public void printName() {
System.out.println("Father print name: " + name);
}
}
|