public class OverreadDemo {
/* * 重写面试题 * *1、 super、this分别是父类和本类的引用, *2、 可调用构造函数super(); * 可传递普通函数;可调用成员变量; */
public static void main(String[] args) {
new B();
}
}
class A {
public A() {
System.out.println("A构造");
}
public void show() {
System.out.println("A");
}
}
class B extends A{
int x = 24;
public B() {
super();//默认父类的构造方法
this.show();
super.show();//调用普通方法
}
public void show() {
System.out.println("B");
System.out.println(this.x);
}
}