AP Computer Science A, AP exams, 15–25%
Unit 1: Using Objects and Methods
Unit 1 establishes Java fundamentals and the habit of using objects before building them. Primitive types, expressions, and casting come first, then object creation, method calls, and the String, Math, and wrapper classes. Precision about types and about integer versus floating-point division is the skill that prevents the most common errors later.
Unit 1: Using Objects and Methods at a glance
- Position
- 1 of 4 units
- Published weighting
- 15–25% in the official framework
- Topics covered
- 6 topics in this guide
What is covered
Topics inside this unit.
These topics describe the scope students most often review for this part of AP Computer Science A. Treat them as a study checklist rather than an exhaustive list of what a single exam form can sample.
- Primitive types and variables
- Declaring variables, the int, double, and boolean types, and the ranges each can hold.
- Expressions and assignment
- Arithmetic operators, operator precedence, compound assignment, and integer versus floating-point division.
- Casting and numeric ranges
- Widening and narrowing conversions, truncation on casting to int, and integer overflow.
- Objects and instantiation
- Reference variables, constructors, the null reference, and the difference between an object and its reference.
- Calling methods
- Method signatures, parameters, return values, void methods, and reading documentation to use a class.
- String, Math, and wrapper classes
- String immutability and its common methods, Math class methods, and autoboxing with Integer and Double.
Study tips
How to practice Objects and Methods.
Section-specific guidance that follows from how this material is usually tested.
- Trace expressions by hand with types annotated; integer division errors are the single most common early mistake.
- Practice reading unfamiliar class documentation and calling its methods correctly, which the exam tests directly.
- Learn the String methods and their exact index conventions, since off-by-one errors are heavily penalized.
Where this fits
Unit 1: Using Objects and Methods is 1 of 4 units in the AP Computer Science A guide, and it carries a published weighting of 15–25% in the official framework. Use the full guide to balance it against everything else you have to review.
Sample Objects and Methods questions
Practice questions, not yet expert-reviewedOriginal practice questions written to the published framework for this section. No expert has reviewed them, and they are not taken from any official exam. Try each one before you open the answer.
- Question 1Foundational
In Java, what is the value of the expression 7 / 2?
- A3
- B3.5
- C3.0
- D4
Show answer
Answer: A. 3
Both operands are int literals, so Java performs integer division and discards the fractional part rather than rounding, giving 3. Writing 7.0 / 2 or casting one operand to double would produce 3.5.
Key insight: Integer division truncates toward zero; it never rounds.
- Question 2Foundational
In Java, what is the value of the expression (int)(9.7)?
- A9
- B10
- C9.7
- D0
Show answer
Answer: A. 9
Casting a double to int truncates the decimal portion instead of rounding, so (int)(9.7) is 9. Getting 10 would require Math.round, which returns the nearest whole number rather than dropping the fraction.
Key insight: A cast to int chops off the decimal part; use Math.round when you want the nearest value.
- Question 3Intermediate
A Java program declares String s = "computer". What value does the call s.substring(3, 6) return?
- Aput
- Bpute
- Cmpu
- Domp
Show answer
Answer: A. put
Indexes start at 0, so position 3 is the letter p, and substring includes the starting index but excludes the ending index. Characters 3, 4, and 5 give put; including index 6 as well would give pute.
Key insight: substring(a, b) includes index a and excludes index b, so its length is b - a.
- Question 4Intermediate
What does this Java code print? String s = "cat"; s.concat(" nap"); System.out.println(s);
- Acat
- Bcat nap
- Cnap
- DNothing, because the code does not compile
Show answer
Answer: A. cat
String objects are immutable, so concat returns a new String rather than changing s, and the returned value is discarded here. Printing cat nap would require assigning the result, as in s = s.concat(" nap").
Key insight: String methods return new Strings; a call whose result is not stored changes nothing.
- Question 5Advanced
What does the Java statement System.out.println(Math.pow(2, 3)); print?
- A8.0
- B8
- C6.0
- D9.0
Show answer
Answer: A. 8.0
Math.pow computes 2 raised to the third power and always returns a double, so the printed value is 8.0 rather than 8. Answering 6.0 multiplies the two arguments, and 9.0 raises 3 to the second power by reversing them.
Key insight: Math.pow returns a double, so its output prints with a decimal point even for whole-number results.
Continue through AP Computer Science A
Practice Objects and Methods deliberately.
Create your Arcade Academy workspace to turn this topic list into spaced-repetition reviews, linked notes, and progress you can act on.