Examveda
Examveda

What is the output of the following program code?
public class Test{
        public static void main(String args[]){
                try{
                        int i;
                        return;
                }
                catch(Exception e){
                        System.out.print("inCatchBlock");
                }
                finally{
                        System.out.println("inFinallyBlock");
                }
        }
}

A. inCatchBlock

B. inCatchBlock inFinallyBlock

C. inFinallyBlock

D. The program will return without printing anything

Answer: Option C


This Question Belongs to Java Program >> Exceptions

Join The Discussion

Comments ( 1 )

  1. Sourodeep Chatterjee
    Sourodeep Chatterjee :
    7 years ago

    Here, no exception is occurring which we have to handle, that's why catch block isn't executing but we all know, whether an exception is caught or not, finally always executes, so all the statements inside of finally block occurs

Related Questions on Exceptions