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


Please Help Members By Posting Answers For Below Questions

What is the use of 'super' keyword inside a constructor?

562


What is time complexity algorithm?

548


Is arraylist ordered in java?

580


Using callable statement how can you pass out parameters, explain with example?

592


What is the advantage of preparedstatement over statement?

571






If two threads have same priority which thread will be executed first ?

846


Can we increase size of array?

574


Can we overload the methods by making them static?

507


What is the purpose of tostring() method in java?

556


Can we define private and protected modifiers for variables in interfaces?

588


What is java life cycle?

541


What is a nested class?

598


What are the types of relation?

577


What is final?

611


what is deadlock? : Java thread

529