您的位置:首页 > 编程语言 > Java开发

java中请给一个Abstract类实现接口的实例!

2014-08-23 08:19 246 查看
2.Abstract类实现接口

马克-to-win:如果实现某接口的类是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("旋转把手,拉!");

}

}

class AdvancedDoorMark_to_win extends Door {

public void open() {

System.out.println("旋转把手,推!");

}

。。。。。。。。。。。。。。。。。

详情请进:http://www.mark-to-win.com/JavaBeginner/JavaBeginner4_web.html#AbstractImplementInterface
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐