import java.io.*; 
class Master { 
  String doFileStuff() throws FileNotFoundException { return "a"; } 

class Slave extends Master { 
  public static void main(String[] args) { 
    String s = null; 
    try {  
         s = new Slave().doFileStuff(); 
    } catch ( Exception x) { 
      s = "b";  
    } 
    System.out.println(s); 
  } 
  // insert code here 
} Which, inserted independently at // insert code here, will compile,  
and produce the output b? (Choose all that apply.) A. String doFileStuff() { return "b"; }  B. String doFileStuff() throws IOException ( return "b"; }  C. String doFileStuff(int. x) throws IOException ( return "b"; }  D. String doFileStuff() throws FileNotFoundException { return "b"; }  E. String doFileStuff() throws NumberFormatException { return "b"; }  F. String doFileStuff() throws NumberFormatException, FileNotFoundException { return "b"; } 
答案  给的是   A D E F    小弟 刚学 java  大侠们帮忙啊    B为什么不对啊    请大家帮忙啊    也希望有人   给的回答  详细点   让小弟 多学些知识谢谢啊    分不是很多    大家见谅啊    呵呵   

解决方案 »

  1.   

    子类只能比父类抛出更少的检查异常,NumberFormatException是runtime异常所以可以抛出。
      

  2.   

    这就是继承中的异常问题!!子类继承了父类之后,覆盖的方法抛出的异常只能小于或等于父类中的方法抛出的异常!!!
    IOException 比 FileNotFoundException 要大。所以不能!!
      

  3.   


    在java里边,子类重写父类的方法,如果父类的方法有抛出异常的语句,子类的方法抛出的异常必须得是
    父类抛出异常的子类,或者和父类抛出的一样;
    如果父类没有抛出异常,子类也不能抛出异常;