标签:案例 ring 手动 向上转型 继承 面试 培训 animal 作用
class Fu {
public void show() {
System.out.println("fu show");
}
}
class Zi extends Fu {
public void show() {
System.out.println("zi show");
}
public void method() {
System.out.println("zi method");
}
}
class Test1Demo {
public static void main(String[] args) {
Fu f = new Zi();
f.method();
f.show();
}
}
class A {
public void show() {
show2();
}
public void show2() {
System.out.println("我");
}
}
class B extends A {
public void show() {
show2();
}
public void show2() {
System.out.println("爱");
}
}
class C extends B {
public void show() {
super.show();
}
public void show2() {
System.out.println("你");
}
}
public class Test2DuoTai {
public static void main(String[] args) {
A a = new B();
a.show();
B b = new C();
b.show();
}
}
A:成员区别
B:关系区别
C:设计理念区别
标签:案例 ring 手动 向上转型 继承 面试 培训 animal 作用
原文地址:http://www.cnblogs.com/GJ-ios/p/5991484.html