Skip to main content

← back to the guide

AP Computer Science A Units 1 and 2: tracing code and writing FRQ methods quiz quiz

12questions. Pick an answer and you'll see why right away.

  1. What is the value of the expression 17 / 5 in Java, where both operands are int?

  2. What does (double) (9 / 2) evaluate to?

  3. What is printed by: System.out.print("X"); System.out.println("Y"); System.out.print("Z");

  4. After int x = 12; x += 3; x *= 2; what is the value of x?

  5. What is the value of "PROGRAM".substring(3, 6)?

  6. Which is the correct way to compare whether two String variables s1 and s2 hold the same text?

  7. Which expression generates a random integer from 1 to 6 inclusive?

  8. What is printed by: System.out.println("Sum: " + 3 + 4);

  9. What does the new keyword do in the statement Account a = new Account(500);?

  10. A void method turnOn() is defined on class Light. Which call is correct for Light lamp = new Light();?

  11. What does Integer.parseInt("25") + 10 evaluate to?

  12. In the code Integer a = 5; int b = a + 3; which Java features are used?