Multiple Choice Question

Quiz Guidelines

 

QID: 
543
Question: 

Identify the exceptions that will be received when the following code snippets are executed.

1. int factorial(int n){
       if(n==1) return 1;
      else return n*factorial(n-1);
   }
Assume that it is called with a very large integer.

2. void printMe(Object[] oa){
       for(int i=0; i<=oa.length; i++)
       System.out.println(oa[i]);
    }
Assume that it is called as such: printMe(null);

3. Object m1(){
       return new Object(); 
    }
    void m2(){
       String s = (String) m1();
    }

Select 1 option

A. Class Cast Exception
Array Index out of Bounds Exception
Stack Overflow Error

B. Class Cast Exception
Array Index Out Of Bounds Exception
Security Exception

C. No Exception Will Be Thrown
Security Exception
Will Not Compile
 
D. Stack Over flow Error
NullPointerException
No Exception Will Be Thrown 

E. Stack Over flow Error
Array Index Out Of Bounds Exception
Class Cast Exception

F. Stack Over flow Error
NullPointerException
NullPointerException
 
G. Security Exception
Null Pointer Exception
No Exception Will Be Thrown
 
H. Stack Overflow Error
Null Pointer Exception
Class Cast Exception

Q&A Set: 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!