AP Computer Science A Unit 1 Exam (2025) – Objects, Methods & Expressions
AP Computer Science A Unit 1 Exam (2025) – Objects, Methods & Expressions
This AP Computer Science A Unit 1 exam is designed for the new 2025 AP CSA 4-Unit curriculum and focuses on foundational programming concepts tested heavily on the AP exam.
Unit 1 introduces students to how Java programs are written, executed, and reasoned about. Mastery of this unit is essential, as these concepts appear in nearly every multiple-choice question and free-response question on the AP CSA exam.
This assessment includes high-difficulty multiple-choice questions modeled after:
- ✔️ The official AP Computer Science A Course and Exam Description (CED)
- ✔️ Barron’s AP CSA challenge problems
- ✔️ CodeHS and AP Classroom progress-check style questions
- ✔️ Common AP CSA pitfalls discussed by high-scoring students and teachers
The questions emphasize conceptual understanding, careful tracing, and precise knowledge of Java syntax and behavior.
- Creating objects and calling methods
- Primitive types vs object references
- Integer vs floating-point arithmetic
- String methods and immutability
- Method parameters and return values
- Using the Java Math API
- Operator precedence and expression evaluation
At the bottom of this exam, you will also complete two concise Free-Response Questions (FRQs) written in the style of AP Classroom Progress Checks, where you will write and test code using a Java sandbox.
Submit the exam at the bottom of the page when completed.
45:00 timer begins automatically when page is uploaded.
Answer explanations and autograder at bottom after submission
Question 1
What is printed?
int a = 7; int b = 2; double x = a / b; System.out.println(x);
Integer division occurs first (7 / 2 = 3), then stored as 3.0.
Question 2
Which expression evaluates to true?
Casting forces floating-point division.
Question 3
Which method call correctly reads an integer from the keyboard?
The method is called on the Scanner object variable.
Question 4
What is the value of x after execution?
int x = 5; x += 4; x *= 2; x -= 3;
5 + 4 = 9 → 9 × 2 = 18 → 18 − 3 = 15 ❌ Wait — correct path is 13? Actually: 5 → 9 → 18 → 15 → correct is C. (Trick: order matters — correct answer is C.)
Question 5
What does the following produce?
System.out.println(Math.abs(-7) + Math.pow(2, 3));
abs(-7) = 7, pow(2,3) = 8 → 7 + 8 = 15.
Question 6
Which is a valid constructor call?
Correct constructor syntax with required argument.
Question 7
What is printed?
String s = "APCSA"; System.out.println(s.substring(2));
substring(2) starts at index 2 through end.
Question 8
Which statement about Strings is TRUE?
All String methods return new objects.
Question 9
What is printed?
String s = "code"; s.toUpperCase(); System.out.println(s);
The returned String is ignored.
Question 10
Which generates a random integer from 0 to 9?
Standard random integer pattern.
Question 11
What is printed?
int x = 4; double y = x / 3; System.out.println(y);
Integer division happens first (4 / 3 = 1), then stored as 1.0.
Question 12
Which call correctly rounds 4.6 to the nearest integer?
Math.round returns a long with correct rounding.
Question 13
What is printed?
String s = "hello"; System.out.println(s.length() - 1);
"hello" has length 5 → last index is 4.
Question 14
Which expression correctly extracts the last character of a String s?
Indices go from 0 to length − 1.
Question 15
What is printed?
int x = 5; System.out.println(x++ + ++x);
x++ returns 5 (x → 6), ++x makes it 7 → 5 + 7 = 12.
Question 16
Which statement about parameters is TRUE?
The reference is copied, not the object itself.
Question 17
What is printed?
String a = "cat"; String b = a; a = "dog"; System.out.println(b);
b still references the original String object.
Question 18
Which compares two Strings for equal text?
equals compares character contents.
Question 19
What is printed?
System.out.println(Math.max(3, Math.min(5, 7)));
min(5,7) = 5 → max(3,5) = 5.
Question 20
Which expression truncates a double to an int?
Casting removes the decimal without rounding.
Question 21
What is printed?
String s = "abc"; System.out.println(s.substring(0, 2));
Substring end index is exclusive.
Question 22
Which method returns the absolute value of a number?
abs is the correct Math API call.
Question 23
What is printed?
int x = (int)(Math.random() * 5); System.out.println(x);
Math.random() returns [0.0, 1.0).
Question 24
Which correctly declares a method that returns a double?
Return type precedes method name.
Question 25
What is printed?
int x = 10; x = x / 4; System.out.println(x);
Integer division truncates decimals.
Question 26
Which is a valid API call?
pow is the correct Math API method.
Question 27
Which operator concatenates Strings?
+ concatenates when one operand is a String.
Question 28
What is printed?
System.out.println("AP" + 5 + 2);
String concatenation proceeds left to right.
Question 29
Which expression evaluates to false?
7 is not less than or equal to 6.
Question 30
Which scenario BEST uses a method with a return value?
Return values send data back to the caller.
📊 Unit 1 Exam Summary
Section II: Free Response Questions (Unit 1)
These questions assess your ability to reason about objects, methods, return values, and expressions. They are written in the style of AP Classroom Progress Checks.
FRQ 1 — Method Return Values
Write a method average that takes two int parameters and returns the average as a double.
Your method must avoid integer division.
public static double average(int a, int b)
Example Calls:
average(4, 6) → 5.0 average(1, 2) → 1.5 average(7, 8) → 7.5
FRQ 2 — String Methods & Immutability
Write a method endsMatch that returns true if the first and last characters of a String are the same.
Assume the string has a length of at least 1.
public static boolean endsMatch(String str)
Example Calls:
endsMatch("radar") → true
endsMatch("apple") → false
endsMatch("a") → true
charAt() returns a char, and length() gives the number of characters in the string. Another option would be using substring(int start, int end)
Java Sandbox
Use the sandbox below to write and test your solutions.