Question: java Analyze the following code: class Test 1 public static void main(String[l args) throws MyException I System.out.println(Welcome to Java); 1 I class MyException extends Error

Analyze the following code: class Test 1 public static void main(String[l args) throws MyException I System.out.println("Welcome to Java"); 1 I class MyException extends Error I I A) You declared an exception in the main method, but you did not throw it. B) You should not declare a class that extends Error, because Error raises a fatal error that terminates the program. C) You cannot declare an exception in the main method. D) The program has a compilation error. A method must declare to throw A) Error C) RuntimeException B) unchecked exceptions D) checked exceptions Selected Answer: C tion 4 What exception type does the following program throw? public class Test 1 public static void main(String[] args) I String s = "abc"; System.out.printn(s.charAt(3)): 1 I A) ArithmeticException B) ArraylndexOutOrBoundsException C) StringlndexOutOrBoundsException D) ClassCastException E) No exception
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
