1. 程式人生 > >11c 11.13

11c 11.13

system main print color http return pri static ()

技術分享

package ty;

abstract class A {
    public abstract void fun();
    
};
package ty;

class B extends A {
    public void fun() {
        System.out.println("what is your name?");
    }

};
package ty;

public class AandB {

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

}

技術分享

package sy;

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

class B extends A{
    public B(String name) {
        super(name);
    }
    
public void fun() { System.out.println(super.getName()); } };
package sy;

public class Adm {
    public static void main(String args[]) {
        B b = new B("大黃");
        b.fun();
    }
};

技術分享

package sy;

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

public class D extends C {

    public D(String name) {
        super(name);
    }
    public void fun() {
        System.out.println(super.getName());
    }

}
package sy;

public class CandD {

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

}

11c 11.13