

MCQOPTIONS
Saved Bookmarks
1. |
What will be the output of the following piece of code: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. ");}} |
A. | here is a NullPointerException. Everything went fine. |
B. | here is a NullPointerException. |
C. | here is a NullPointerException. There is an Exception. |
D. | his code will not compile, because in Java there are no pointers. |
Answer» B. here is a NullPointerException. | |