What is displayed on the console when running the following program?

```
public class Test {
public static void main(String[] args) {
try {
p();
System.out.println("After the method call");
}
catch (NumberFormatException ex) {
System.out.println("NumberFormatException");
}
catch (RuntimeException ex) {
System.out.println("RuntimeException");
}
}
public class Test {
public static void main(String[] args) {
try {
p();
System.out.println("After the method call");
}
catch (NumberFormatException ex) {
System.out.println("NumberFormatException");
}
catch (RuntimeException ex) {
System.out.println("RuntimeException");
}
}
```
a. The program displays NumberFormatException.
b. The program displays NumberFormatException followed by After the method call.
c. The program displays NumberFormatException followed by RuntimeException.
d. The program has a compile error.
e. The program displays RuntimeException.
Key:a It should be A. The main method invokes the method p. In p,

a. The program displays NumberFormatException.
The main method invokes the method p. In p, Integer.parseInt(s) causes a NumberFormatException. The method p is now terminated. The NumberFormatException exception is handled in the main method. So NumberFormatException is displayed.

Computer Science & Information Technology

You might also like to view...

Common practice is to add two spaces at the end of a sentence

Indicate whether the statement is true or false

Computer Science & Information Technology

The Beijing Eagle Union consists of Chinese hackers

Indicate whether the statement is true or false.

Computer Science & Information Technology