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

```
public class Test {
public static void main(String[] args) {
try {
String s = "5.6";
Integer.parseInt(s); // Cause a NumberFormatException

int i = 0;
int y = 2 / i;
System.out.println("Welcome to Java");
}
catch (Exception ex) {
System.out.println(ex);
}
}
}
```
a. An exception is raised due to Integer.parseInt(s);
b. An exception is raised due to 2 / i;
c. The program has a compile error.
d. The program compiles and runs without exceptions.


a. An exception is raised due to Integer.parseInt(s);
Both (A) and (B) would cause exception, but (A) occurred first, so the exception is due to (A).

Computer Science & Information Technology

You might also like to view...

Write a method named displayList() that has one parameter of type Vector and has a return value of void. The method uses an iterator to display the contents of the Vector.

What will be an ideal response?

Computer Science & Information Technology

An enhanced for loop is simpler to write than a standard for loop with an index.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The less precise way to move objects in report Layout view is to ____.

A. use the Move command to move objects B. use the arrow keys on the keyboard to move objects C. drag objects D. use the insert key on the keyboard to move objects

Computer Science & Information Technology

Your computer crashes in the middle of you writing a term paper. You lose the paper because you had not saved a copy yet. You lost your paper because it was in ________.

a) Binary Form b) The CPU c) RAM d) ROM

Computer Science & Information Technology