Exceptions
- Which of these keywords is not a part of exception handling?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Exceptional handling is managed via 5 keywords – try, catch, throws, throw and finally.
- What is the output of this program?
public class exception_Example
{
static void throwexception() throws ArithmeticException
{
System.out.print("50");
throw new ArithmeticException ("Exception");
}
public static void main(String args[])
{
try
{
throwexception();
}
catch (ArithmeticException e)
{
System.out.println("M");
}
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
50M
- When does Exceptions in Java arises in code sequence?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Exceptions in Java are run-time errors.
- What is the output of this program?
public class I_LOVE_YOU
{
public static void main(String args[])
{
try
{
int You, Me, You_Me;
You = 0;
Me = 5;
You_Me = Me/You;
System.out.print("I MISS U ALWAYS...");
}
catch(ArithmeticException e)
{
System.out.print("I LOVE YOU");
}
finally
{
System.out.print(" FOREVER...");
}
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
I LOVE YOU FOREVER...
- Which of these keywords must be used to monitor for exceptions?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
try