4 Replies Latest reply on Jul 5, 2011 1:53 PM by 872842


      Hi All,

      class A{
      public void process(){ S.o.p("A");
      class B extends A{
      public void process() throws IOException{
      throw new IOException();
      p s v m(String []args){
      try{(new B().process();)}
      catch(IOException e){ S.o.p("Exception");}

      result: compile time error in line "public void process() throws IOException"
      plz help me to find the reason.?

      regards ,
        • 1. Re: OCJP
          Did you read my previous post correctly? Use code tag to post any codes.
          • 2. Re: OCJP
            help me to find the reason?
            The reason is stated in the compiler error message. What part of it didn't you understand?
            • 3. Re: OCJP
              Here subclass B which extends from class A is overiding the method process(). While overiding you cannot declare a checked exceptions declaration in the subclass when you dont have any exception in the parent class. As per the contract of overiding you can have either have broader exceptions or no exceptions inherit from your parent class to your subclass.
              • 4. Re: OCJP
                Thank you v.much for Ur kind consideration... I got some idea.