2.Abstract类实现接口

马克-to-win:如果实现某接口的类是abstract类,则它可以不实现该接口所有的方法。但其非abstract的子类中必须拥有所有抽象方法的实在的方法体;(当然它abstract爹的也算作是它的)

If a class implements an interface, it must implement all of its methods in the interface, otherwise, this class must be an abstract class. if it is an abstract class, it can leave some methods in the interface unimplemented.refer to the following example.

例1.2---
interface OpenClose {
    void open();
    void close();
}
abstract class Door implements OpenClose {
    public void close() {
        System.out.println("旋转把手,拉!");
    }
}
/*AdvancedDoorMark_to_win这个类不需要实现close()。因为它已经有close()。它的close()位置在它的超类"Door"。
AdvancedDoorMark_to_win does not need to implement close(), because it already has
close(), the only thing is that the position of its close() is inside its
super class "Door"
*/
class AdvancedDoorMark_to_win extends Door {
    public void open() {
        System.out.println("旋转把手,推!");
    }

}
public class Test {
    public static void main(String args[]) {
        AdvancedDoorMark_to_win d = new AdvancedDoorMark_to_win();
        d.open();
        d.close();
    }
}

更多内容请见原文,文章转载自:https://blog.csdn.net/qq_44639795/article/details/103111035

最新文章

  1. 【SQL语句】 - Ctrl+3 查询表属性的存储过程
  2. linux 安装samba
  3. 遍历Map
  4. mongodb数据导入导出以及备份恢复
  5. jquery 温故而知新 Ul 相关的操作
  6. 无锁队列以及ABA问题
  7. IT 需要知道的一些专业名词和解释 (长期更新)
  8. sql SELECT时的with(nolock)选项说明
  9. 修改Chrome默认搜索引擎为Google.com
  10. 69. Sqrt(x)
  11. C&python文件读写效率
  12. YII 主题
  13. pureMVC介绍及学习
  14. CTF中常见的加解密(经典)
  15. 剪格子---(dfs回溯)
  16. grpc 使用总结
  17. js基础-函数基础
  18. Drool实战系列(二)之eclipse安装drools插件
  19. SGU536 Berland Chess
  20. 白话 Ruby 与 DSL 以及在 iOS 开发中的运用

热门文章

  1. WPF优秀组件推荐之MahApps
  2. JZ-065-矩阵中的路径
  3. LeetCode-098-验证二叉搜索树
  4. LeetCode-020-有效的括号
  5. 操作系统以及python的简介
  6. .NET的两种部署模式,了解一下
  7. 矩池云助力科研算力免费上"云",让 AI 教学简单起来
  8. Python 让我舅舅的书法作品和 PIL 库发生点美的误会
  9. centos7 安装 nginx-1.18.0 并设置开机自启动
  10. k8s原来这么简单(一)核心组件与工作原理