0% 0 votes, 0 avg 28 1234567891011121314151617181920 This quiz randomly generates 20 questions as asked in AP Computer Science A (AP CSA) - Programming in Java. Congratulations! AP Computer Science A (AP CSA) - Programming in Java This quiz randomly generates 20 questions (in 30 mins) as asked in AP Computer Science A (AP CSA) - Programming in Java. 1 / 20 What output will be produced by invoking secondTestMethod for a Tester object, assuming that testArray contains 3, 4, 5? 3 4 5 4 5 6 5 6 7 0 0 0 No output will be produced. An ArrayIndexOutDfBoundsException will be thrown. The array will not be changed by the increment method. Nor will the local variable element! What will be changed by increment is the copy of the parameter during each pass through the loop. 2 / 20 Question 3 4 5 10 13 3 / 20 What is the output? public static void main(String[] args) { int a = (int)(1 * Math.random()); int b = (int)(1 * Math.random()); if (a > b && a > c) System.out.println(a); else if (b > a && b > c) System.out.println(b); else System.out.println(c); } Error No output The value of b The value of a The code generates random numbers for 'a', 'b', and 'c' but 'c' is not defined. This will result in an error during compilation due to the undefined variable 'c'. 4 / 20 What is the output? 10 : 30 : 4 10 : 30 : 5 10 : 30 : 6 Compilation Error 5 / 20 Question I only II only III only I and II only I and III only 6 / 20 Question (1) n == 1 && n == 4 (2) k += n (1) n == 1 && n == 4 (2) k += 4 (1) n == 1 || n == 4 (2) k += 4 (1) n == 1 || n == 4 (2) k += n (1) n == 1 || n == 4 (2) k = n - k 7 / 20 What is the output? A B A element 0 B element 1 A Null Pointer Exception is thrown at runtime. A 0 B 1 8 / 20 What is the output? [1, 2, 3] [1, 3, 4] [2, 3, 4] Compilation fails [3, 4, null] 9 / 20 What is the output? 2416 0010010016 2216 4416 10 / 20 What is the length of the myIntegers array initialized in the code below? int a = 8; a *= 2; a = a * 3 / 5; int[] myArray = new int[a]; for(int i = 0; i < myArray.length; i++) { myArray[i] = i % 4; } 8 9 10 16 int a = 8; -> a is 8 a *= 2; -> a is 8 * 2, which is 16 a = a * 3 / 5; -> a is 16 * 3 / 5, which is 48 / 5. In integer division, this results in a being 9. int[] myArray = new int[a]; -> The array myArray is initialized with a length of 9. 11 / 20 ASCII is a character-encoding scheme that uses a numeric value to represent each character. For example, the uppercase letter "G" is represented by the decimal (base 10) value 71. A partial list of characters and their corresponding ASCII values are shown in the table below. A-65 B-66 C-67 D-68 ASCII characters can also be represented by binary numbers. According to ASCII character encoding, which of the following letters is represented by the 8-bit binary value: 0100 0010 ASCII Character: A ASCII Character: B ASCII Character: D The table does not contain the value represented by the binary number 0100 0010 12 / 20 Question list[i] = (int) (Math.random() * 101); list.add((int) (Math. random() * 101)); list[i] = (int) (Math.random() * 100); list.add(new Integer (Math. random() * 100)) list [i] = (int) (Math.random() * 100) + 1; 13 / 20 Which assertion is true just before each execution of the while loop? arr[first) < key < arr[last] arr[first] ≤ key ≤ arr[last] arr[first] < key < arr[last] or key is not in arr arr[first] ≤ key ≤ arr[last] or key is not in arr key < arr[first] or key ≥ arr [last] or key is not in arr 14 / 20 What is the result of the following expression in Java? 5 6 8 11 15 / 20 8 bits is enough to represent 256 different numbers. How many total bits do you need to represent 512 (twice as many) numbers? 9 bits 10 bits 16 bits 17 bits 16 / 20 Which of the following expressions is equivalent to !(x < 5 && y >= 10)? x >= 5 || y < 10 x >= 5 && y < 10 x > 5 || y <= 10 x > 5 && y < 10 A: This is De Morgan’s Law. You negate x < 5 (which becomes x >= 5), negate y >= 10 (which becomes y < 10), and change the && to ||. 17 / 20 Question I only II only III only II and III only I, II and III 18 / 20 What will the array arr look like after the following loop finishes? {1, 3, 5, 7, 9} {1, 3, 6, 10, 15} {3, 5, 7, 9, 5} {1, 2, 3, 4, 5} 19 / 20 What is the output? Answer = 0 Invalid calculation Compilation fails only at line n1. Compilation fails only at line n2. Compilation fails at line n1 and line2. // ans is initialized in the try-catch block, can not be seen outside the block 20 / 20 Question Which of the following is a false statement about the methods? equals, lessThan, and toString are all accessor methods. increment is a mutator method. Time() is the default constructor. The Time class has two constructors. There are no static methods in this class. Your score is 0% Restart quiz