Menu

(Solved) : 17 Consider Following Snippet Code Double 15 32 58 Int B Int Int 0 Q44084332 . . .

17. Consider the following snippet of code. double[] a = {1.5,3.2,5.8}; int[] b = (int) a; for (int i=0; i<a.length; i++) a[i18. Consider the following snippet of code. public static void main(String[] args) { String s = testing; for (int i=0; i<5;

17. Consider the following snippet of code. double[] a = {1.5,3.2,5.8}; int[] b = (int) a; for (int i=0; i<a.length; i++) a[i] ++; System.out.println(Arrays.toString (b)); What is the outcome? A. Prints “[1, 3, 5]” B. Prints “[2, 4, 6)” C. Prints “[1, 3, 6)” D. Compile-time error (ANSWER) E. Run-time error 18. Consider the following snippet of code. public static void main(String[] args) { String s = “testing”; for (int i=0; i<5; i++) count(s); System.out.println(s.length()); public static String count(String s) { return (s + 123); What is the outcome? A. Prints 8 (ANSWER) B. Prints 11 C. Prints 23 D. Compile-time error E. Run-time error 19. What is the best way to determine if two variables a and b of type String refer to objects that represent the same sequence of characters? Assume neither value is null. A. To check if a.length == b.length, then check that each character matches using a.charAt[i] in a for loop. B. To use a recursive algorithm that uses a.substring to compare one half of the string at the time C. With the statement a == b; D. With the statement a.toCharArray ( ) == b.toCharArray(); E. With the statement a.equals(b); (ANSWER) Show transcribed image text 17. Consider the following snippet of code. double[] a = {1.5,3.2,5.8}; int[] b = (int) a; for (int i=0; i

Expert Answer


Answer to 17. Consider the following snippet of code. double[] a = {1.5,3.2,5.8}; int[] b = (int) a; for (int i=0; i…

OR