zoukankan      html  css  js  c++  java
  • 接口练习题(接口和多继承之间的关系和应用)

    package com.Summer_0427.cn;
    
    /**
     * @author Summer
     * 接口和多继承之间的关系和应用
     * 应用实例:计算机及其设备、插排与两项电和三项电的应用;
    计算机作为商品的继承
    */ interface ThreeElectronic{ void threeService(); } interface TwoElectronic{ void twoService(); } //接口的继承和多继承,实现了接口的功能合并和 interface Socket extends ThreeElectronic,TwoElectronic{ void socketService(); } class goods{ private String type; public goods(String type) { this.type = type; } public String getType() { System.out.println(this.type+"属于家电类"); return type; } } class Computer extends goods implements Socket{ public Computer(String type) { super(type); } @Override public void threeService() { System.out.println("计算机本身用三项电通电"); } @Override public void twoService() { System.out.println("计算机上的外置设备用两项电通电"); } @Override public void socketService() { System.out.println("计算机上连接的插排进行供电"); } } public class TestElectronic { public static void main(String[] args) { Computer cp = new Computer("戴尔电脑"); cp.threeService(); cp.twoService(); cp.socketService(); cp.getType(); } }
  • 相关阅读:
    Linux makefile教程之概述一[转]
    Valid Parentheses
    Letter Combinations of a Phone Number
    机器学习经典分类算法 —— C4.5算法(附python实现代码)
    3Sum Closest
    3Sum
    Integer to Roman
    寒假文献阅读(四)
    Longest Common Prefix
    Roman to Integer
  • 原文地址:https://www.cnblogs.com/summerdata/p/10780773.html
Copyright © 2011-2022 走看看