AP Computer Science A

The AP Computer Science A Java Quick Reference

Built into Bluebook: every Java library method the exam may use.

Stringlength, substring, indexOf, equals, compareTo, split
Mathabs, pow, sqrt, random
ArrayListsize, add, get, set, remove
FilesFile and Scanner: nextInt, next, nextLine, hasNext

Also on it

  • Integer.MINVALUE, Integer.MAXVALUE and Integer.parseInt.
  • Double.parseDouble.
  • Object's equals and toString.

Not on it

  • String methods such as charAt or toUpperCase: use substring.
  • Arrays and Collections helpers: write the loop.

Try 2 questions

Question 1
Consider the following code segment.String tag = "player_one_42"; int u = tag.indexOf("_"); String first = tag.substring(0, u); String rest = tag.substring(u + 1); System.out.println(first + " " + rest.indexOf("_"));What is printed as a result of executing the code segment?
Question 2
Consider the following code segment.double a = Math.sqrt(49) + Math.pow(2, 3); int b = (int) Math.pow(10, 2) / 8; System.out.println(a + " " + b);What is printed as a result of executing the code segment?

FAQ

Do you get a Java reference on the AP Computer Science A exam?

Yes. The Java Quick Reference is built into Bluebook, and schools may print it for you.