1 public interface TestTwo { 2 void testName() throws Exception; 3 void TestTwo()throws Exception; 4 }
1 public class TestThree implements TestTwo { 2 //默认的,如果在接口中不写访问范围的话,那么默认为public和abstract 3 //显然只有在接口定义了抛出异常,在实现的方法才能抛出异常,否则不能抛出异常 4 //在接口中如果定义了异常的话,那么,在实现的可以不显示出来,只有当用到异常的抛出时,才显示出来 5 @Override 6 public void testName() throws Exception { 7 throw new Exception(); 8 } 9 10 @Override 11 public void TestTwo() { 12 // TODO Auto-generated method stub 13 14 } 15 }