Exception Handling in Java Mcqs

Our collections of Multiple choice questions and answers focuses on study of Exception Handling in Java. These questions are chosen from a collection of most authoritative and best reference books on Java. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Exception Handling in Java topic comprehensively.

3.
Which of the following should be true of the object thrown by a thrown statement?

Should be assignable to String type

Should be assignable to Exception type

Should be assignable to Throwable type

Should be assignable to Error type

5.
What is the output of this program?<br/>Note : Execution command line : $ java exception_handling

    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a = args.length;
                int b = 10 / a;
                System.out.print(a);
            }
            catch (ArithmeticException e) 
            {
                    System.out.println("1");
            }
        }
    }

0

1

Compilation Error

Runtime Error

6.
What is the output of this program?

    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                throw new NullPointerException ("Hello");
            }
            catch(ArithmeticException e)
            {
         System.out.print("B");         
            }
        }
    }

A

B

Compilation Error

Runtime Error

8.
Which of these statements is incorrect?

Try block need not to be followed by catch block

Try block can be followed by finally block instead of catch block

Try can be followed by both catch and finally block

Try need not to be followed by anything

9.
What is the output of this program?

    class Output 
    {
        public static void main(String args[]) 
        {
           try 
           {
               int a = 0;
               int b = 5;
               int c = b / a;
               System.out.print("Hello");
           }
           catch(Exception e) 
           {
               System.out.print("World");
           } 
        }
    }

Hello

World

HelloWOrld

Compilation Error

10.
What is the output of this program?

    class Output 
    {
        public static void main(String args[]) 
        {
           try 
           {
               int a = 0;
               int b = 5;
               int c = a / b;
               System.out.print("Hello");
           }
           catch(Exception e) 
           {
               System.out.print("World");
           } 
        }
    }

Hello

World

HelloWOrld

Compilation Error

0Shares
0
Scroll to Top