1、TestIntace.java
package com.chase.abstrac; /**
* 接口
* @author Chase
*
* @date 2013-10-21 下午02:29:12
*
* @version V1.0
*/
public interface TestIntface { void test1();//方法1 void test2();//方法2 void test3();//方法3
}
2、TestAbstract.java
package com.chase.abstrac; /**
* 实现TestIntface接口的 抽象类
* @author Chase
*
* @date 2013-10-21 下午02:29:57
*
* @version V1.0
*/
public abstract class TestAbstract implements TestIntface { public void test1(){System.err.println("我是test1");}; public void test2(){}; public void test3(){System.err.println("我是test3");}
}
3、TestExtendsAbstract.java
package com.chase.abstrac; /**
* 继承 实现TestIntface接口的 抽象类 的 子类
* @author Chase
*
* @date 2013-10-21 下午02:31:04
*
* @version V1.0
*/
public class TestExtendsAbstract extends TestAbstract { public void test3() {
System.out.println("test3()");
} }
4、TestMain.java
package com.chase.abstrac; /**
* 程序入口类
* @author Chase
*
* @date 2013-10-21 下午02:32:14
*
* @version V1.0
*/
public class TestMain { static TestIntface intface = new TestExtendsAbstract(); public static void main(String[] args) {
intface.test3();
intface.test1(); }
} 运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfsAAACJCAIAAACkdAb7AAAE0UlEQVR4nO3dMXLTTACG4b1VZuACugMFwx1U0ZDhEFQiLSUlMzQqaFJS0Oco+gsSW7JWiq3gxPm/55kdJqPI6zjA681aScqf37fX19dfv/36+u3Xn9+3xhnHj49v33z8+VL39Zz3PhnfP7+5+vxj222/fCjvbjbfdfeuvP/y7I/3PI9lacLuXXmZv9bn/1S8msf789PVJf3Dm4zyR/Gfbfz4+LaUUspz/Gu4jOL//HRVSillc/Fvb96ffNub9+XBvy3sU8eGx7I6vjRP+9w+5a4/lAOnfRibPhUv+HhPHd8/v3mW/+anD8U3DMNIGZPiXwPw/zUp/vBKlFJe+kMAeH0UHyCF4gOkUHyAFIoPkOIFin/XNfeX8DZd9YSuabq70dmz0xQfYINK8bum7f/F1NV5+nYf+rtJ2kdnTG83O6D4AFtMi79fft/bp7Zv90eni+79bZrmfj2+Ms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