504). Which of these exceptions handles the situations when an illegal argument is used to invoke a method?

[A]IllegalException
[B] Argument Exception
[C]IllegalArgumentException
[D]IllegalMethodArgumentExcepetion

Show Answer

505). Which of these exceptions will be thrown if we declare an array with negative size?

[A]IllegalArrayException
[B]IllegalArraySizeExeption
[C]NegativeArrayException
[D]NegativeArraySizeExeption

Show Answer

507). Which of these exceptions will be thrown if we use null reference for an arithmetic operation?

[A]ArithmeticException
[B]NullPointerException
[C]IllegalAccessException
[D]IllegalOperationException

Show Answer

508). Which of these class is used to create user defined exception?

[A]java.lang
[B]Exception
[C]RunTime
[D]System

Show Answer

509). What will be the output of the following Java program?
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a[] = {1, 2,3 , 4, 5};
                for (int i = 0; i < 7; ++i) 
                    System.out.print(a[i]);
            }
            catch(ArrayIndexOutOfBoundsException e) 
            {
        	System.out.print("0");        	
            }
        }
    }

[A]12345
[B]123450
[C]1234500
[D]Compilation Error

Show Answer

510). What will be the output of the following Java program?
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a[] = {1, 2,3 , 4, 5};
                for (int i = 0; i < 5; ++i) 
                    System.out.print(a[i]);
                int x = 1/0;
            }
            catch(ArrayIndexOutOfBoundsException e) 
            {
        	System.out.print("A");        	
            }
            catch(ArithmeticException e) 
            {     	
                System.out.print("B");
            }
        }
    }

[A]12345
[B]12345A
[C]12345B
[D] Compilation Error

Show Answer

511). What will be the output of the following Java program?
    class exception_handling 
    {
            static void throwexception() throws ArithmeticException 
            {        
                System.out.print("0");
                throw new ArithmeticException ("Exception");
            }
            public static void main(String args[]) 
            {
            try 
            {
                throwexception();
            }
            catch (ArithmeticException e) 
            {
                    System.out.println("A");
            }
        }
    }

[A]A
[B]0
[C]0A
[D]Exception

Show Answer

512). What will be the output of the following Java program?
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
             {
                int a = 1;
                int b = 10 / a;
                try 
                {
                     if (a == 1)
                         a = a / a - a;
                     if (a == 2) 
                     {
                         int c[] = {1};
                         c[8] = 9;
                     }
                finally 
                {
                    System.out.print("A");
                }
 
            }
            catch (NullPointerException e) 
            {
                    System.out.println("B");
            }
        }
    }

[A]A
[B]B
[C]AB
[D]BA

Show Answer

513). What will be the output of the following Java program?Note: Execution command line: $ java exception_handling one two
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a = args.length;
                int b = 10 / a;
                System.out.print(a);
                try 
                {
                     if (a == 1)
                         a = a / a - a;
                     if (a == 2) 
                     {
                         int c = {1};
                         c[8] = 9;
                     }
                }
                catch (ArrayIndexOutOfBoundException e) 
                {
                    System.out.println("TypeA");
                }
                catch (ArithmeticException e) 
                {
                    System.out.println("TypeB");
                }
        }
    }

[A]TypeA
[B]TypeB
[C]0TypeA
[D]0TypeB

Show Answer