Multiple Choice Question

Quiz Guidelines

 

Multiple Choice Question

QID: 
536

Which of the following are standard Java exception classes?

Select 2 options 

A. FileNotFoundException 
B. InputException 
C. CPUError 
D. MemoryException 
E. SecurityException 

Multiple Choice Question

QID: 
535

What will the following code print when run?

public class Test{ 
static String j = ""; 
public static void method( int i){ 
 try{   if(i == 2){     
throw new Exception();   }   
j += "1";  }  
catch (Exception e){  
 j += "2";   
return;  }  
finally{   
j += "3";  }  
j += "4"; } 
public static void main(String args[]){  
method(1);  
method(2);  
System.out.println(j); } }

Select 1 option 

A. 13432 
B. 13423
C. 14324 
D. 12434 
E. 12342 

Multiple Choice Question

QID: 
531

What will the following program print when run?

public class TestClass{  
public static void main(String[] args){     
try{        
System.exit(0);     }     
finally{         
System.out.println("finally is always executed!");    
 }  } }

Select 1 option

A. It will print  "finally is always executed!" 
B. It will not compile as there is no catch block. 
C. It will not print anything. 
D. An exception will be thrown 
E. None of the above. 

Multiple Choice Question

QID: 
530

What will the following code print when compiled and run?

abstract class Calculator{   
abstract void calculate();   
public static void main(String[] args){      
System.out.println("calculating");      
Calculator x = null;     
 x.calculate();   } }

Select 1 option 

A. It will not compile. 
B. It will not print anything and will throw NullPointerException 
C. It will print calculating and then throw NullPointerException. 
D. It will print calculating and will throw NoSuchMethodError 
E. It will print calculating and will throw MethodNotImplementedException 

Multiple Choice Question

QID: 
529

Given the class

// Filename: Test.java 

public class Test{   
public static void main(String args[]){      
for(int i = 0; i< args.length; i++){         
System.out.print("  "+args[i]);      }   } } 

Now consider the following 3 options for running the program:

a: java Test 
b: java Test param1 
c: java Test param1 param2 

Which of the following statements are true?

Select 2 options 

A. The program will throw java.lang.ArrayIndexOutofBoundsException on option a. 
B. The program will throw java.lang.NullPointerException on option a. 
C. The program will print Test param1 on option b. 
D. It will print param1 param2 on option c. 
E. It will not print anything on option a.

Pages

Search the Web

Custom Search

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