1. A class containing abstract methods is called an abstract class. If a class Contains one of more abstract methods, the class itself must be qualified(限定,修饰) as a abstract.
  2. If you inherit from an abstract class you want to make objects of the new type, you must provide method definitions for all the abstract methods in the base class. If you don't(and you may choose not to), then the derived class is also abstract, and the compiler will force you to qualify that class with the abstract keyword.
  3. It's possible to make a class abstract without including any abstract methods. This is useful when you've got a class in which it doesn't make sense to have any abstract methods, and yet you want to prevent any instances of that class.
  4. If you do inherit from a non-interface, you can inherit from only one. All the rest of the base elements must be interfaces. You place all the interface names after the implements keyword and separate them with commas. You can have as many interfaces ay you want. You can upcast to each interface, because each interface is an independent type.
  5. 如果你创建的新的类即继承了某个类同时又实现了某些接口,那么在类声明的时候,被继承的类必须是第一个出现的,然后才是接口(如果你不这样做的话,编译器就会报错)。
  6. Keep in mind that one of the core reasons for interfaces is: to upcast to more than one base type(and the flexibility that this provides). However, a second reason for using interfaces is the same as using an abstract base class: to prevent the client programmer from making an object of this class and to establish that it is only an interface. This brings up a question: Should you use an interface or an abstract class? If it's possible to create your base class without any method definitions or member variables, you should always prefer interfaces to abstract classes. In fact, if you know something is going to be a base class, you can consider making it an interface.
  7. Normally, you can use extends with only a single class, but extends can refer to multiple base interfaces when building a new interface(The interface names are simply separated with commas).
  8. 我们知道一个接口可以继承多个接口,也可以继承一个类同时又实现多个接口,如果它继承的多个接口(或者继承的类和实现的多个接口)中有同名同参但是返回值不同的方法时会出现什么情况呢?答案是会出现命名冲突,编译不通过,因为两个方法仅仅是返回值类型不同并不能构成重载。因此我们应当尽量避免在不同的接口中用两个相同的方法名,尤其是这两个接口常常被一个类一同实现的时候更应该额外注意这一点。
  9. 在Java SE5 之前,Java 中还没有enum 关键字,接口就成为提供一组常量值的一个简便的工具(在一些遗留的老代码中可能会看到这种情况)。接口中的成员变量,自动的是public static final 的。这些值被存储在静态存储区中。
  10. 许多人痴迷于接口的特性,总是想尽办法在一切地方应用它,其实这是一种过早优化(万恶之源:P)。An appropriate guideline is to prefer classes to interfaces. Start with classes, and if it becomes clear that interfaces are necessary, then refactor. Interfaces are a great tool, but they can easily be overused.

最新文章

  1. XPath函数——字符串函数(转载)
  2. Fedora下的解压
  3. tooltip提示插件
  4. python 参数
  5. 关于myeclipse中maven项目转换相关设置
  6. Dynamic view
  7. java查询WFS服务
  8. Serv-U搭建FTP服务器
  9. 如何删除windows服务(sc.exe删除和注册表删除两种方法)
  10. logstash 防止实际处理时间跟事件产生时间略有偏差
  11. POJ 3892 RSA Factorization
  12. [iOS Animation]-CALayer 显示动画
  13. Cookie SQL注入
  14. Django之分页
  15. 《DSP using MATLAB》Problem 7.23
  16. BugkuCTF 矛盾
  17. 使用sigaction函数
  18. .NET压缩图片保存 .NET CORE WebApi Post跨域提交 C# Debug和release判断用法 tofixed方法 四舍五入 (function($){})(jQuery); 使用VUE+iView+.Net Core上传图片
  19. VS:error C3872: '0xe044': this character is not allowed in an identifier解决方法
  20. python格式化

热门文章

  1. UVA11722 Jonining with Friend
  2. Django项目:CRM(客户关系管理系统)--19--11PerfectCRM实现King_admin分页显示条数
  3. 数据库完整性 ch.5
  4. day18 16.dbcp连接池使用介绍
  5. [Git高级教程(二)] 远程仓库版本回退方法 - 梧桐那时雨 - CSDN博客
  6. 使用Cmder 安装 Composer 出现 "attempt to call a nil value"
  7. 安装tengine及淘宝会话保持模块
  8. Djngo 请求的生命周期
  9. Vue--vue中的组件、组件绑定事件和数据、私有组件、子组件,父子组件参数互传
  10. SAS之大话PDV