JAVA接口的基本测试------JAVA

public class Interface
{
    public static void main(String[] args)
    {
        System.out.println(Flyable.max_speed);
        System.out.println(Flyable.min_speed);
        //类与接口是实现关系
        Bullet b = new Bullet();
        b.attack();
        b.fly();
        Flyable f = new Bullet();
        f.fly();
    }
}

interface Flyable
{
    public static final int min_speed = 0;
    public static final int max_speed = 7900;

    public abstract void fly();
}

interface Attack
{
    public abstract void attack();
}

class Airplane implements Flyable
{
    public void fly()
    {
        System.out.println("Fly");
    }
}

class Bullet implements Attack,Flyable
{
    public void attack()
    {
        System.out.println("子弹袭击");
    }

    public void fly()
    {
        System.out.println("飞出去击中");
    }
}

interface A
{
    public abstract void A();
}

interface B
{
    public abstract void B();
}

interface C extends A,B
//接口可以多继承
{

}

class D implements C
{
    public void A()
    {

    }

    public void B()
    {

    }
}

public class Interface
{
    public static void main(String[] args)
    {
        System.out.println(Flyable.max_speed);
        System.out.println(Flyable.min_speed);
        //类与接口是实现关系
        Bullet b = new Bullet();
        b.attack();
        b.fly();
        Flyable f = new Bullet();
        f.fly();
    }
}

interface Flyable
{
    public static final int min_speed = 0;
    public static final int max_speed = 7900;

    public abstract void fly();
}

interface Attack
{
    public abstract void attack();
}

class Airplane implements Flyable
{
    public void fly()
    {
        System.out.println("Fly");
    }
}

class Bullet implements Attack,Flyable
{
    public void attack()
    {
        System.out.println("子弹袭击");
    }

    public void fly()
    {
        System.out.println("飞出去击中");
    }
}

interface A
{
    public abstract void A();
}

interface B
{
    public abstract void B();
}

interface C extends A,B
//接口可以多继承
{

}

class D implements C
{
    public void A()
    {

    }

    public void B()
    {

    }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值