0% 0 votes, 0 avg 19 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? [1, 2, 3] [1, 3, 4] [2, 3, 4] Compilation fails [3, 4, null] 2 / 20 What is the output? 5:5 5:10 10:10 Compilation Fails 3 / 20 Which code fragment, when inserted at line 6, enables the code to print true? String str2 = str1; String str2 = new String(str1); String str2 = sb1.toString(); String str2 = "Duke"; 4 / 20 What is the output? 10 : 30 : 4 10 : 30 : 5 10 : 30 : 6 Compilation Error 5 / 20 What is the output? S 6 S 5 S -1 w 7 // no white space before and after "Sweat Sweat", so trim() is not effective // 6th character in str is still S. -- charAt(6) gives S // str.indexOf("Sw", 1); means return the index numver of characters "Sw" but start to count from 1 6 / 20 What is the output? An exception is thrown at runtime. 07-31-2014 2014-07-31 2014-09-30 7 / 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 Four words become HiHowAreYou, since its length is more than 4, nothing will be removed and HiHowAreYou removed will be printed. 8 / 20 What is the output? Compilation fails. The program compiles, but it prints nothing. HiHowAreYou removed An UnsupportedOperationException is thrown at runtime. 9 / 20 What is the output? An exception is thrown at runtime. 07-31-2014 2014-07-31 2014-09-30 10 / 20 What is the output? 1:2:3:4:5: 1:2:3: Compilation fails An ArrayOutOfBoundsException is thrown at runtime 11 / 20 Which statement is true about the switch statement? It must contain the default section. The break statement, at the end of each case block, is optional. Its case label literals can be changed at runtime. Its expression must evaluate to a collection of values. The switch statement in Java provides a way to control program flow by executing different blocks of code based on the value of a single expression. It offers an alternative to using multiple if-else if-else statements, often leading to more readable and concise code for handling multiple conditional branches. 12 / 20 What is the output? A B B A A Null Pointer Exception is thrown at runtime. A 0 B 1 13 / 20 What is the output? [Robb, Rick, Bran] [Robb, Rick] [Robb, Bran, Rick, Bran] An exception is thrown at runtime. 14 / 20 What is the output ? -3 4 5 6 3 4 3 6 5 4 5 6 3 6 4 6 15 / 20 What is the output? 4W 100 Auto 4W 150 Manual null 0 Auto 4W 150 Manual Compilation fails only at line n1 Compilation fails only at line n2 Compilation fails at both line n1 and line n2 Java do not allow super() and this() to be called concurrently in the same constructor. super() means calling the constructor from the parent class. this() means calling another constructor within your own 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 is the output? Compilation fails at line n2. Compilation fails at line n1 20:20 10:20 18 / 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. 19 / 20 What is the output? A B C A B C D E A B D E Compilation fails. 20 / 20 What is the output? 400 200 200 200 200 200 Compilation fails. Your score is 0% Restart quiz