26 lines
393 B
Java
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);
|
|
}
|
|
}
|