5 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

Overall Stats

Attempted 281
Correct 83
Incorrect 89
Viewed 109

Answers

Guest
Guest
Awa Kone
Awa Kone - 1 month ago

Awa Kone from Berrechid, Morocco is saying Compilation fails because of an error at line 9. is correct answer

ayoub benigmim
ayoub benigmim - 1 month ago

ayoub benigmim from Casablanca, Morocco is saying Ex0 caught is correct answer

Souad El
Souad El - 1 month ago

Souad El from Casablanca, Morocco is saying Ex0 caught is correct answer

Salwa Nouamani
Salwa Nouamani - 1 month ago

Salwa Nouamani from Casablanca, Morocco is saying Ex0 caught is correct answer

Cos Sinus
Cos Sinus - 1 month ago

Cos Sinus from Casablanca, Morocco is saying exception caught is correct answer

Related Questions

sub class of writer class is?

  • [A] byte writer
  • [B] character writer

Exception is subclass of ____ class

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

Which method is used to print the description of the exception?

  • [A] printStackTrace()
  • [B] printExceptionMessage()
  • [C] printStackMessage()
  • [D] printExceptionTrace()