首页 > 代码库 > 接口小练习

接口小练习

package jiekou3;

public interface Vehicle {

    public void start();
    public void stop();
    
    
}
package jiekou3;

public class Car implements Vehicle {

    public void start() {
        System.out.println("开的飞快");
        }

        @Override
        public void stop() {
        System.out.println("不好停车");
        }

}
package jiekou3;

public class Bike implements Vehicle {

    public void start() {
        System.out.println("自行车开的慢吞吞");

    }

    public void stop() {
        System.out.println("停车非常好停");

    }

}
package jiekou3;

public class Test {

    public static void main(String[] args) {
    Bike b=new Bike();
    b.start();
   b.stop();
    }

}

 

接口小练习