CoreJava/exp4/PolymorphicDemo.java
2024-05-09 09:10:51 +08:00

26 lines
393 B
Java

package exp4;
class A{
String member = "fu";
void show(){
System.out.println(this.member);
}
}
class B extends A{
String member = "zi";
void show(){
System.out.println(this.member);
}
}
public class PolymorphicDemo {
public static void main(String[] args){
A a = new B();
a.show();
System.out.println(a.member);
}
}