6 years ago in Java Exception Handling

What will be the output of the program?

class Exc0 extends Exception { }
class Exc1 extends Exc0 { } /* Line 2 */
public class Test
{
public static void main(String args[])
{
try
{
throw new Exc1(); /* Line 9 */
}
catch (Exc0 e0) /* Line 11 */
{
System.out.println("Ex0 caught");
}
catch (Exception e)
{
System.out.println("exception caught");
}
}
}

[A] Ex0 caught
[B] exception caught
[C] Compilation fails because of an error at line 2.
[D] Compilation fails because of an error at line 9.
Loading...
Next Question

Create your Digital Resume For FREE on your name's sub domain "yourname.wcard.io". Register Here!


Overall Stats

Attempted 164
Correct 48
Incorrect 50
Viewed 66

Answers

Guest
Guest
SASMITA SAHU
SASMITA SAHU - 4 years ago

SASMITA SAHU from Hyderabad, India is saying exception caught is correct answer

Radwa Maher
Radwa Maher - 4 years ago

Radwa Maher from Romania is saying Compilation fails because of an error at line 9. is correct answer

Kuheli Mitra
Kuheli Mitra - 4 years ago

Kuheli Mitra from Bangalore, India is saying Ex0 caught is correct answer

Shanu Sulabh
Shanu Sulabh - 4 years ago

Shanu Sulabh from Bengaluru, India is saying Ex0 caught is correct answer

Intan Izreen
Intan Izreen - 4 years ago

Intan Izreen from Puchong Batu Dua Belas, Malaysia is saying Compilation fails because of an error at line 2. is correct answer

Related Questions

______ is a superclass of all exception classes.

  • [A] Exception
  • [B] Throwable
  • [C] RuntimeException
  • [D] IOException

What happen behind the code int a=50/0;

  • [A] object of exception class thrown
  • [B] Error in code