JavaQuizzes

Quiz Guidelines

 

Multiple Choice Question

QID: 
547

Java's Exception mechanism helps in which of the following ways?

Select 2 options

A. It allows creation of new exceptions that are custom to a particular application domain.
B. It improves code because error handling code is clearly separated from the main program logic. 
C. It enhances the security of the application by reporting errors in the logs.
D. It improves the code because the exception is handled right at the place where it occured.
E. It provides a vast set of standard exceptions that covers all possible exceptions.

Multiple Choice Question

QID: 
548

Which of the following standard Java exception classes extend java.lang.RuntimeException?

Select 4 options

A. java.lang.SecurityException
B. java.lang.ClassCastException
C. java.lang.NullPointerException
D. java.lang.CloneNotSupportedException
E. java.lang.IndexOutOfBoundsException

Multiple Choice Question

QID: 
549

Given the following program, which statement is true?

class SomeClass{
public static void main( String args[ ] ){
if (args.length == 0 ){
System.out.println("no arguments") ;
}
else{
System.out.println( args.length + " arguments") ;
}
}
}

Select 1 option

A. The program will fail to compile.
B. The program will throw a NullPointerException when run with zero arguments.
C. The program will print no arguments and 1 arguments when called with zero and one arguments.
D. The program will print no arguments and 2 arguments when called with zero and one arguments.
E. The program will print no arguments and 3 arguments when called with zero and one arguments.

True or False

QID: 
550

The following program will print java.lang.ArithmeticException: / by zero

class Test{
public static void main(String[] args){
int d = 0;
try{
int i = 1 / (d* doIt());
} catch (Exception e){
System.out.println(e);
}
}
public static int doIt() throws Exception{
throw new Exception("Forget It");
}
}

Select 1 option

A. True
B. False

Multiple Choice Question

QID: 
551

Consider that you are writing a set of classes related to a new Data Transmission Protocol and have created your own exception hierarchy derived from java.lang.Exception as follows:

enthu.trans.ChannelException
+-- enthu.trans.DataFloodingException,
enthu.trans.FrameCollisionException

You have a TransSocket class that has the following method:

long connect(String ipAddr) throws ChannelException

Now, you also want to write another "AdvancedTransSocket" class, derived from "TransSocket" which overrides the above mentioned method. Which of the following are valid declaration of the overriding method?

Select 2 options

A. int connect(String ipAddr) throws DataFloodingException
B. int connect(String ipAddr) throws ChannelException
C. long connect(String ipAddr) throws FrameCollisionException
D. long connect(String ipAddr) throws Exception
E. long connect(String str)

Pages

Search the Web

Custom Search

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