You are not logged in.
Pages:: 1
#1 2015-06-15 06:36:34
NullPointerException:
Java Quizzes Java Language Exceptions
Directions:
class Person{
public void talk() {}
}
public class Test{
public static void main(String args[]){
Person p = null;
try{
p.talk();
}
catch(NullPointerException e){
System.out.print("There is a NullPointerException. ");
}
catch(Exception e){
System.out.print("There is an Exception. ");
}
System.out.print("Everything went fine. ");
}
}
Question:
What will be the output of the following piece of code:
Option A):
There is a NullPointerException. Everything went fine
Option B):
There is a NullPointerException. There is an Exception
Option C):
There is a NullPointerException
Option D):
This code will not compile, because in Java there are no pointers
Correct Answer is Option A):
There is a NullPointerException. Everything went fine
You cannot discover the new oceans unless you have the courage to lose the sight of the shore.
Offline
2015-06-15 06:36:34
- Advertisement
- Ads By Google
Re: NullPointerException:
\n
Pages:: 1