首页 > 代码库 > abstract小练习

abstract小练习

package ab2;

public abstract class Vehicle {

    
    public abstract String nowheel();
}
package ab2;

public class Car extends Vehicle{

    public  String nowheel(){
        String l="四个轮子";
   return l;
    }
}
package ab2;

public class Mo extends Vehicle {
    public String nowheel(){
        String s="两个轮子";
        return  s;
    }

    
}
package ab2;

public class Test {
public static void main(String[] args) {
    Car c=new Car();
    System.out.println(c.nowheel());
    Mo m=new Mo();
    System.out.println(m.nowheel());
}
}

 

abstract小练习