62,614
社区成员
发帖
与我相关
我的任务
分享
class SuperClass {
SuperClass() throws Exception {
System.out.println(this.getClass().getName());
}
void show() {
System.out.println(super.getClass().getName());
show2();
}
void show2() {}
}
public class SubClass extends SuperClass {
SubClass() throws Exception {}
void show() {
super.show();
System.out.println(super.getClass().getName());
}
void show2() {
System.out.println(super.getClass().getSuperclass().getName());
}
public static void main(String args[]) throws Exception {
SuperClass s = new SubClass();
s.show();
}
}
(SuperClass)
SuperClass() throws Exception {
System.out.println(this.getClass().getName());
}
(SubClass)
void show() {
super.show();
System.out.println(super.getClass().getName());
}
(SuperClass)
void show() {
System.out.println(super.getClass().getName());
show2();
}
class Father extends Object{
//......
}
class Son extends Father{
//......
}
子类show()方法
void show() {
super.show();
System.out.println(super.getClass().getName());
}
父类的构造方法:
SuperClass() throws Exception {
System.out.println(this.getClass().getName());
}