Java Programming and Technical Programming

What will be the output of the program?

public class RTExcept
{
public static void throwit ()
{
System.out.print("throwit ");
throw new RuntimeException();
}
public static void main(String [] args)
{
try
{
System.out.print("hello ");
throwit();
}
catch (Exception re )
{
System.out.print("caught ");
}
finally
{
System.out.print("finally ");
}
System.out.println("after ");
}
}

A. hello throwit caught finally after
B. Compilation fails
C. hello throwit RuntimeException caught after
D. hello throwit caught

Read Solution (Total 2)

Java Other Question

Which of the given fact(s) are true with respect to the blocks and order of execution of blocks in "Exceptions"?

A. The try block can be followed by finally block and then followed by the catch blocks
B. One or more catch blocks which are exception handlers are placed immediately after the try block
C. Catch block has an argument which can accept an argument of any exception type and it is the name of a class that inherits from the Throwable class
D. The finally block always executes when the try block exits or when an exception occurs
E. The finally block is not executed when there is a return statement in the try block
Predict the output

import java.io.IOException;

public class Exception1{

public static void main(String[] args)

{

try

{

throw new IOException();

}

catch(IOException | Exception ex)

{

System.out.println(ex + " handled ");

}

}

}

A. program won't compile
B. runtime exception
C. program will compile
D. None of the above