AP CSA Unit 1 Exam (2025) - Objects, Methods & Expressions
AP Computer Science A Unit 1 Exam (2025)
Objects, Methods & Expressions
This exam is designed for the 2025-2026 AP CSA 4-Unit curriculum and focuses on foundational programming concepts.
Unit 1 introduces how Java programs are written, executed, and reasoned about. These concepts appear in nearly every AP CSA exam question.
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 from high-scoring students and teachers
- 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 evaluation
30 Multiple Choice Questions | 45 minutes | Submit at bottom when complete
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 the result is stored as 3.0 in the double variable.
Question 2
Which expression evaluates to true?
Casting 5 to double forces floating-point division: 5.0 / 2 = 2.5.
Question 3
Which method call correctly reads an integer from the keyboard using a Scanner object named input?
Instance methods are called on the object variable, not the class name.
Question 4
What is the value of x after execution?
int x = 5; x += 4; x *= 2; x -= 3;
Step by step: 5 + 4 = 9, then 9 * 2 = 18, then 18 - 3 = 15.
Question 5
What does the following produce?
System.out.println(Math.abs(-7) + Math.pow(2, 3));
Math.abs(-7) = 7, Math.pow(2,3) = 8.0, so 7 + 8.0 = 15.0.
Question 6
Which is a valid constructor call?
Correct constructor syntax: Type variableName = new Type(arguments);
Question 7
What is printed?
String s = "APCSA"; System.out.println(s.substring(2));
substring(2) returns characters from index 2 to the end: "CSA".
Question 8
Which statement about Strings is TRUE?
Strings are immutable. All String methods return new String objects rather than modifying the original.
Question 9
What is printed?
String s = "code"; s.toUpperCase(); System.out.println(s);
The returned uppercase String is ignored. The original String s is unchanged because Strings are immutable.
Question 10
Which generates a random integer from 0 to 9 (inclusive)?
Math.random() returns [0.0, 1.0). Multiply by 10 gives [0.0, 10.0). Casting to int gives 0-9.
Question 11
What is printed?
int x = 4; double y = x / 3; System.out.println(y);
Integer division (4 / 3 = 1) happens first, then the result is stored as 1.0 in the double.
Question 12
Consider the following code segment. What value is returned by Math.round(4.6)?
Math.round() rounds to the nearest integer. 4.6 rounds to 5 (returns a long).
Question 13
What is printed?
String s = "hello"; System.out.println(s.length() - 1);
"hello" has length 5, so 5 - 1 = 4. This is also the last valid index.
Question 14
Which expression correctly extracts the last character of a String s?
Indices go from 0 to length-1. The last character is at index length() - 1.
Question 15
What is printed?
int x = 5; System.out.println(x++ + ++x);
x++ returns 5 (then x becomes 6), ++x increments first (x becomes 7) then returns 7. So 5 + 7 = 12.
Question 16
Which statement about method parameters in Java is TRUE?
Java passes everything by value. For objects, 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 "cat". Reassigning a to "dog" does not affect b.
Question 18
Which correctly compares two Strings s1 and s2 for equal content?
The equals() method compares String contents. The == operator compares references.
Question 19
What is printed?
System.out.println(Math.max(3, Math.min(5, 7)));
Math.min(5, 7) = 5, then Math.max(3, 5) = 5.
Question 20
Which expression truncates a double x to an int (removing the decimal without rounding)?
Casting to int truncates the decimal portion without rounding.
Question 21
What is printed?
String s = "abc"; System.out.println(s.substring(0, 2));
substring(0, 2) returns characters from index 0 up to (but not including) index 2: "ab".
Question 22
Which Math class method returns the absolute value of a number?
Math.abs() returns the absolute value.
Question 23
What range of values can x have after this statement executes?
int x = (int)(Math.random() * 5);
Math.random() returns [0.0, 1.0). Multiplying by 5 gives [0.0, 5.0). Casting to int gives 0, 1, 2, 3, or 4.
Question 24
Which correctly declares a method that returns a double?
Correct syntax: access modifier, return type, method name, parameters.
Question 25
What is printed?
int x = 10; x = x / 4; System.out.println(x);
Integer division: 10 / 4 = 2 (decimal is truncated).
Question 26
Which is a valid Math API call to calculate 2 raised to the power of 3?
Math.pow(base, exponent) calculates base^exponent.
Question 27
Which operator concatenates Strings in Java?
The + operator concatenates Strings when at least one operand is a String.
Question 28
What is printed?
System.out.println("AP" + 5 + 2);
Left to right: "AP" + 5 = "AP5", then "AP5" + 2 = "AP52". String concatenation, not addition.
Question 29
Which expression evaluates to false?
7 is not less than or equal to 6, so this is false.
Question 30
Which scenario BEST demonstrates when to use a method with a return value?
Return values are used when the method needs to send data back to the caller.
Unit 1 Exam Results
Section II: Free Response Questions
These questions assess your ability to write Java code involving objects, methods, return values, and expressions.
FRQ 1 - Method Return Values
Write a method average that takes two int parameters and returns their average as a double.
Your method must avoid integer division truncation.
public static double average(int a, int b)
Example Calls:
average(4, 6) returns 5.0 average(1, 2) returns 1.5 average(7, 8) returns 7.5
FRQ 2 - String Methods
Write a method endsMatch that returns true if the first and last characters of a String are the same, and false otherwise.
Assume the string has a length of at least 1.
public static boolean endsMatch(String str)
Example Calls:
endsMatch("radar") returns true
endsMatch("apple") returns false
endsMatch("a") returns true
charAt() to get individual characters, or substring() to extract portions of a String.
Java Sandbox
Use the sandbox below to write and test your FRQ solutions:
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]