11.13第十一次作业

package Hzy;

public abstract class A {
    private String name;
    public A(String name) {
        this.name=name;
    }
    public String getName() {
        return this.name;
    }
    public abstract void fun();
}
package Hzy;

public class B extends A {
    //抽象类不能实例化
    public B(String name) {
        super(name);
    }
    public void fun() {
        System.out.println(super.getName());
    }

}
package Hzy;

public class DemoAB {

    public static void main(String[] args) {
        B b =new B("悟空");
        b.fun();
    }
}

 

posted on 2017-11-14 15:44  黄宗禹  阅读(91)  评论(0编辑  收藏  举报

导航