源题目是这样——
下列代码输出结果是什么——    class SuperClass
   {
          public void method() throws IOException
          {
                //statements
           }
   }
   public class SubClass extends SuperClass
   {
           public void method throws ArrayIndexOutOfBoundsException,IOException
           {
                  //statements
            }
   }提出问题是这个程序的扩充,形式大概那样。请教~~~

解决方案 »

  1.   

    SubClass.java:11: method() in SubClass cannot override method() in SuperClass; overridden method does not throw java.io.IOException
               public void method() throws IOException
                           ^
    1 error你真的编译通过 了吗?我编译怎么不通过
      

  2.   

    ArrayIndexOutOfBoundsException是RuntimeException的子类,不需在throws中出现
      

  3.   

    第二个代码能通过 的,因为ArrayIndexOutOfBoundsException 是运行时异常,不用catch也行的. RuntimeException的子类.
      

  4.   

    绝对不可以!
    还是用try catch finally吧
      

  5.   

    楼主,你开始给出的程序应该是不能通过编译的(我没试验,懒)但是下面的应该可以(我又懒了一次)主要原因在于ArrayIndexOutOfBoundsException与IOException之间的不同java.lang.Object
      |
      +--java.lang.Throwable
            |
            +--java.lang.Exception
                  |
                  +--java.lang.RuntimeException   <-注意这里
                        |
                        +--java.lang.IndexOutOfBoundsException
                              |
                              +--java.lang.ArrayIndexOutOfBoundsException
    java.lang.Object
      |
      +--java.lang.Throwable
            |
            +--java.lang.Exception
                  |
                  +--java.io.IOExceptionArrayIndexOutOfBoundsException属于RuntimeException,是运行时异常,这种异常很难再编程的时候预见到所以有的RuntimeException都不必在throws语句中显示的写出也就是说throws ArrayIndexOutOfBoundsException,IOException 和throws IOException是没有区别的你明白了吗?