Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1186960
  • 博文数量: 233
  • 博客积分: 6270
  • 博客等级: 准将
  • 技术积分: 1798
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-26 08:32
文章分类

全部博文(233)

文章存档

2011年(31)

2010年(202)

我的朋友

分类: Java

2010-11-18 15:41:22

实现接口的非抽象类需要实现接口中的全部方法,但是对抽象类没有要求
 
如下图示:
 

interface A {
     void a1();
     void a2();
     void a3();
}

abstract class B_A implements A {
     void a1() {
        System.out.println("test A1");
     }
}

class C extends B_A {
        void a2() {
           System.out.println("test A2");
        }

        void a3() {
           System.out.println("test A3");
        }
}

从上例中,我们知道C类中已经包含了接口A的全部方法的实现,其中a1方法是在抽象类B_A中实现的。

阅读(457) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~