For unlimited access to Study Guides, a Grade+ subscription is required.
18. What is the value of the String referred to by the variable s after the following code executes? String fun = "bcd"; String a = ""; for (int i = 0; i < fun.length(); i++) { a = a + (char) (fun.charAt(i) + 3); String s = ""; for (int i = 0; i < a.length(); i++) { S = S + (char) (a.charAt(i) + 'A' -'a');
18. What kind of exception would be caught below? public class Test public static void main(String[] args) try String[] s = new String[3]; S[1] = "Hello"; s [2] = "World"; for (int i = 0; i <= s.length - 1; i++) System.out.print (s[i].length()); catch (Exception e) System.out.println(e); (A) NullPointerException (B) ArrayIndexOutOfBoundsException (C) Input MismatchException (D) NumberFormatException (E) No exception would be caught.
22. What prints when the following code executes? public static void main(String[] args) { String s = "word"; mystery(s); public static void mystery (Strings) { String t = ""; for (int i=0; i