MCQ
Single Best Answer
Not Set
QPredict the output:
public class Test{
public static void main(String args[]){
try{
String arr[] = new String[10];
arr = null;
arr[0] = "one";
System.out.print(arr[0]);
}catch(Exception ex){
System.out.print("exception");
}catch(NullPointerException nex){
System.out.print("null pointer exception");
}
}
}
ID: #2336
Java Exception MCQ
597 views
Question Info
#2336Q ID
Not SetDifficulty
Java Exception MCQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option D
Explanation
Compilation fails saying NullPointerException has already been caught.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic