static class father{
String name = " i am father";
father(){
System.out.println("how are you");
}
father(String name){
System.out.println(name);
}
public void getName() {
System.out.println("who are you");
}
}
static class son extends father{
son(){
super();
super.getName();
}
son(String name){
super(name);
}
}
public static void main(String[] args) {
son s = new son();
s = new son("i am zhangsan");
}
public class This {
String name = "zhangsan";
String passwd = "123456";
This(String name,String passwd){
this.name = name;
this.passwd = passwd;
System.out.println(this.name+" "+this.passwd);
}
This(){
this.prt();
}
public void prt(){
System.out.println("我是被调用的函数");
System.out.println(this.name+" "+this.passwd);
}
public static void main(String[] args) {
This t = new This("lisi","987654");
This t1 = new This();
}
}
Super()和this()的作用super的作用:super的作用是在子类函数中引用父类中的方法;static class father{ String name = " i am father"; father(){ System.out.println("how are you"); } fathe...