Exceptions


  1. Which of these keywords is not a part of exception handling?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Exceptional handling is managed via 5 keywords – try, catch, throws, throw and finally.


  1. 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");
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    50M



  1. When does Exceptions in Java arises in code sequence?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Exceptions in Java are run-time errors.


  1. 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...");
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    I LOVE YOU FOREVER...



  1. Which of these keywords must be used to monitor for exceptions?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    try