What is displayed on the console when running the following program? public class Quiz2C { public static void main(String[] args) { try { method(); System.out.println(“After the method call”); } catch (NumberFormatException ex) { System.out.println(“NumberFormatException”); } catch (RuntimeException ex) { System.out.println(“RuntimeException”); } } private static void method() { String s = “8.3”; Integer.parseInt(s); int i = 0; int y = 2 / i; System.out.println(“Welcome to Java”); } } Question 3 options: The program displays NumberFormatException The program displays NumberFormatException followed by After the method call The program displays NumberFormatException followed by RuntimeException The program has a compilation error
What is displayed on the console when running the following program?
public class Quiz2C
{
public static void main(String[] args)
{
try
{
method();
System.out.println(“After the method call”);
}
catch (NumberFormatException ex)
{
System.out.println(“NumberFormatException”);
}
catch (RuntimeException ex)
{
System.out.println(“RuntimeException”);
}
}
private static void method()
{
String s = “8.3”;
Integer.parseInt(s);
int i = 0;
int y = 2 / i;
System.out.println(“Welcome to Java”);
}
}
options:
| The program displays NumberFormatException |
| The program displays NumberFormatException followed by After the method call |
| The program displays NumberFormatException followed by RuntimeException |
| The program has a compilation error |