Home / Java Programming / Exceptions :: Discussion

Discussion :: Exceptions

  1. What will be the output of the program?

      public class X 
      {    
       public static void main(String [] args) 
      }
         try       
         {          
             badMethod();          
             system.out.print("A");    
       }         
       catch (Exception ex)   
       {           
       System.out.print("B");       
       }           
         finally      
         {            
            System.out.print("C"); 
       }       
       system.out.print("D");    
       }           
       public static void badMethod() {}  
       }   
    

     

  2. A.

    AC

    B.

    BC

    C.

    ACD

    D.

    ABCD

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    There is no exception thrown, so all the code with the exception of the catch statement block is run.


Be The First To Comment