1
2
3
4
5
|
package cn.ch.w; public abstract class A { public abstract void fun(); } |
1
2
3
4
5
6
7
|
package cn.ch.w; public class B extends A{ public void fun(){ System.out.println( "嗨!你好小蘑菇!!" ); } } |
1
2
3
4
5
6
7
8
9
|
package cn.ch.w; public class ABstractDemo { public static void mian(String args[]){ B b= new B(); b.fun(); } } |
1
2
3
4
5
6
7
8
9
10
11
12
|
package cn.ch.w; public abstract class A { private String name; public A(String name){ this .name=name; } public String getnName(){ return this .name; } public abstract void fun(); } |
1
2
3
4
5
6
7
8
9
10
|
package cn.ch.w; public class B extends A{ public B(String name){ super (name); } public void fun(){ System.out.print( super .getnName()); } } |
1
2
3
4
5
6
7
8
9
10
|
package cn.ch.w; public class AbstractDemo { public static void main(String[] args) { B b= new B( "小蘑菇!!" ); b.fun(); } } |