33. try {
34. // some code here
35. } catch (NullPointerException e1) {
36. System.out.print(”a”);
37. } catch (RuntimeException e2) {
38. System.out.print(”b”);
39. } finally {
40. System.out.print(”c”);
41. }
What is the result if a NullPointerException occurs on line
34?
1 c
2 a
3 ab
4 ac
Answer Posted / guest
1)
try {
throw new NullPointerException();
} catch (NullPointerException e1) {
System.out.print("a");
} catch (RuntimeException e2) {
System.out.print("b");
} finally {
System.out.print("c");
}
Ans: ac
2) try {
new NullPointerException();
} catch (NullPointerException e1) {
System.out.print("a");
} catch (RuntimeException e2) {
System.out.print("b");
} finally {
System.out.print("c");
}
Ans: c
Is This Answer Correct ? | 5 Yes | 2 No |
Post New Answer View All Answers
What is the use of 'super' keyword inside a constructor?
What is time complexity algorithm?
Is arraylist ordered in java?
Using callable statement how can you pass out parameters, explain with example?
What is the advantage of preparedstatement over statement?
If two threads have same priority which thread will be executed first ?
Can we increase size of array?
Can we overload the methods by making them static?
What is the purpose of tostring() method in java?
Can we define private and protected modifiers for variables in interfaces?
What is java life cycle?
What is a nested class?
What are the types of relation?
What is final?
what is deadlock? : Java thread