接口练习题(通过类可以实现多个接口的功能)

package com.Summer_0427.cn;

/**
 * @author Summer
 * 通过类可以实现多个接口的功能
 * 应用实例:计算机及其设备连接两项电和三项电的应用
 */
interface ThreeElectronic{
    void threeService();
}

interface TwoElectronic{
    void twoService();
}

class Computer implements ThreeElectronic,TwoElectronic{
    @Override
    public void threeService() {
        System.out.println("计算机本身用三项电通电");    
    }

    @Override
    public void twoService() {
        System.out.println("计算机上的外置设备用两项电通电");
        
    }
    
}

public class TestElectronic {

    public static void main(String[] args) {
        Computer cp = new Computer();
        cp.threeService();
        cp.twoService();
    }

}

 

posted @ 2019-04-27 22:08  Geek张东坡  阅读(404)  评论(0编辑  收藏  举报