0% 0 votes, 0 avg 23 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 is the output? int sum is 30 ; float sum is 30.0 int sum is 30 ; double sum is 30.0 Integer sum is 30 ; double sum is 30.0 Integer sum is 30 ; float sum is 30.0 2 / 20 What is the output ? Compilation fails 3 5 0 0 9 25 Class constructor will initialize values of x and y. No problem and easy. 3 / 20 Question for (int i = 0; i <= list.size() ; i++) list.set(i, new Clown)) ; list.add(list.size(), new Clown()); Clown c = list.get(list.size()); Clown c = list.remove(list.size()); list.add(-1, new Clown ()); 4 / 20 What is the output? 1 2 3 0 01 2 3 0 0 An Exception is thrown at run time. 1 2 3 0 01 2 3 1 2 31 2 3 5 / 20 Refer to the Point, Quadrilateral, and Rectangle classes below: I only II only III only I and Il only II and IlI only 6 / 20 Question 32 225 255 256 272 7 / 20 What is the output ? 3 6 9 3 6 12 3 6 18 3 12 18 3 12 36 8 / 20 The insert method has two string parameters and one integer parameter. The method returns the string obtained by inserting the second string into the first starting at the position indicated by the integer parameter. For example, if strl contains xy and str2 contains cat, then a0a1...aposb0b1...an-1 a0a1...apos+1b0b1...an-1 a0a1...apos-1b0b1...an-1 a0a1...an-1b0b1...am-1 a0a1...apos-1b0b1...am-1 9 / 20 Question c = 6, d = ?, p = 9 , t = ? c = 5, d = ?, p = ? , t = 10 c = 6, d = ?, p = ? , t = ? c = 5, d = 9, p = ? , t = 10 c = 9, d = 9, p = ? , t = ? 10 / 20 Question 1 6 7 12 -3 12 4 12 -3 6 11 / 20 Question 74 47 734 743 347 12 / 20 Question Round-off eror was caused by calculations with floating-point numbers. Type boolean was not recognized by an obsolete version of Java. An overflow error was caused by entering numbers that were too large. c and d should have been cast to integers before testing for equality. Bad test data were selected. 13 / 20 Number systems with different bases such as binary (base-2) and decimal (base-10) are all used to view and represent digital data. Which of the following is NOT true about representing digital data? At one of the lowest levels of abstraction, all digital data can be represented in binary using only combinations of the digits zero and one. The same value (number) can have a different representation depending on the number system used to represent it. Groups of bits can be used to represent abstractions, including but not limited to numbers and characters. Some large numbers cannot be represented in binary and can only be represented in decimal. 14 / 20 Question The Caller object in the driver class was not created with new. The programmer forgot the return statement in getList that returns the list of integers. The declaration of myNumbers is incorrect. It needed to be private ArrayList<Integer> myNumbers = null; In the getList method, an attempt was made to add an Integer to an ArrayList that had not been created with new. The shuffleNumbers algorithm went out of range, causing a null Integer to be shuffled into the ArrayList. 15 / 20 Which three statements are true about the structure of a Java class? (Choose three.) A class cannot have the same name as its field. A public class must have a main method. A class can have final static methods. A class can have overloaded private constructors. Fields need to be initialized before use. Methods and fields are optional components of a class. 16 / 20 Which three pieces of code, when inserted independently, set the value of amount to 100? At line n1 insert: public CheckingAccount() { amount = 100; } At line n2 insert: this.amount = 100; At line n2 insert: amount = 100; line n1 insert: public CheckingAccount(){ this.amount = 100; } At line n2 insert: acc.amount = 100; At line n1 insert: public CheckingAccount(){ acc.amount = 100; } Option B : this.amount = 100; // ==>Cannot use this in a static context Option C : amount = 100; // ==> Cannot make a static reference to the non-static field amount Option F : acc.amount = 100; // ==> acc cannot be resolved to a variable 17 / 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. 18 / 20 Question The area of each Quadrilateral in quadList will be printed A compile-time error will occur, stating that there is no area method in abstract class Quadrilateral. A compile-time error will occur, stating that there is no getLabels method in classes Rectangle, Parallelogram, or Square. A NullPointerException will be thrown. A ClassCastException will be thrown. 19 / 20 Question Math.pow returns an int, while Math. sqrt returns a double. x was imprecisely calculated in a previous program statement. The computer stores floating-point numbers with 32-bit words. There is round-oft error in calculating the pow and sqrt functions. There is overflow error in calculating the pow function. 20 / 20 What is the output? 400 200 200 200 200 200 Compilation fails. Your score is 0% Restart quiz