Q.- Given this code for the classes MyException and Test:-
public class MyException extends RunTimeException
{
}
public class Test
{
public static void main(String[ ] args)
{
try
{
methodl();
}
catch (MyException no)
{
System.out.print("A");
}
}
public static void methodl()
{
// line n1
try
{
throw 3 > 10 ? new MyException( )
: new IOException( );
}
catch (IOException ie)
{
System.out.println("I");
}
catch (Exception re)
{
System.out.print("B");
}
}
}
What is the result?
Α) Α
B) AB
С) B
D) I
E) A compile time error occurs at line n1.
⧪ please give your answer in a comment section.
public class MyException extends RunTimeException
{
}
public class Test
{
public static void main(String[ ] args)
{
try
{
methodl();
}
catch (MyException no)
{
System.out.print("A");
}
}
public static void methodl()
{
// line n1
try
{
throw 3 > 10 ? new MyException( )
: new IOException( );
}
catch (IOException ie)
{
System.out.println("I");
}
catch (Exception re)
{
System.out.print("B");
}
}
}
What is the result?
Α) Α
B) AB
С) B
D) I
E) A compile time error occurs at line n1.
⧪ please give your answer in a comment section.
6 Comments
I
ReplyDeleteD
ReplyDeleteD
ReplyDeleteI
ReplyDeleteE
ReplyDeleteAns - I
ReplyDelete