1、接口也可以继承
(1)Java中的类是属于单继承的。Java中的接口也可以实现继承,并且接口可以实现多继承。
注意:接口只能继承接口,不可以继承普通类和抽象类,否则会报错!
2、标记接口
标识接口是没有任何方法和属性的接口。它仅仅表明它的类属于一个特定的类型,供其他代码来测试。使用标记接口的唯---目的是可以用instanceof进行类型查询例如:if (obj ihstanceof Cloneable) ......
在Java中常见的标记接口有Serializable接口和Clone接口。
(1)java.io.Serializable 接口
java.io.Serializable接口仅仅表明,实现该接口的类,可以实现类的序列化和反序列化。标记接口仅仅是一个标记,此种接口并没有抽象方法。
(2)java.lang.Cloneable 接口
java.lang.Cloneable接口表明0bject.clone(方 法可以合法地对该类实例进行按字段复制。实现此接口的类应该使用公共方法重写Object.clone。
今日问题:无
明天复习第六章