5 years ago in Java Exception Handling

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()
{
throw new Error(); /* Line 22 */
}
}

[A] ABCD
[B] Compilation fails.
[C] C is printed before exiting with an error message.
[D] BC is printed before exiting with an error message.
Loading...
Next Question

Overall Stats

Attempted 369
Correct 86
Incorrect 119
Viewed 164

Answers

Guest
Guest
ayoub benigmim
ayoub benigmim - 1 month ago

ayoub benigmim from Casablanca, Morocco is saying Compilation fails. is correct answer

Souad El
Souad El - 1 month ago

Souad El from Casablanca, Morocco is saying C is printed before exiting with an error message. is correct answer

Salwa Nouamani
Salwa Nouamani - 1 month ago

Salwa Nouamani from Casablanca, Morocco is saying BC is printed before exiting with an error message. is correct answer

Cos Sinus
Cos Sinus - 1 month ago

Cos Sinus from Casablanca, Morocco is saying C is printed before exiting with an error message. is correct answer

AHMED SOULIMANI
AHMED SOULIMANI - 1 month ago

AHMED SOULIMANI from Casablanca, Morocco is saying ABCD is correct answer

Related Questions

In case of multiple catch blocks,______

  • [A] The superclass exception must be caught first
  • [B] The superclass exception can not caught first
  • [C] Either super or subclass can be caught first.
  • [D] None of these

what is checked exception

  • [A] Error
  • [B] Runtime Erroe
  • [C] SQL Exception