For unlimited access to Study Guides, a Grade+ subscription is required.
12. What will the following print ? public class Test public static void main (String[] args) boolean bl = true; boolean b2 = false; boolean b3 = true; if ((bl && b2) || (b2 && b3) || b2) System.out.print("ok"); if ((bl && b2) || (b2 && b3) 11 (bl || b2)) System.out.println("dokey"); (A) No output is produced (B) ok (C) dokey (D) Compile-time error (E) ok dokey
24. Consider the Insertion Sort (code 3) algorithm described in the appendix. How can we change this code to have the algorithm sort from largest to smallest instead? (A) Change line 9 to: a[j-1] = a[j]; (B) Change line 7 to: while(j >0 && a[j - 1] 0; i--) (E) Change line 12 to: a[i] = x;
16. Suppose m and n are both int variables with positive values. Which of the following boolean expressions are guaranteed to be equal in value to the expression that follows? (m % n == 0 && n % m == 0) • I. m == • II. ! (m III. ! (m n n) > n) (A) I and III (B) I, II, and III (C) I and II (D) None of the expressions are guaranteed to be the same. (E) I only