Unit 1 Practice Test: Using Objects and Methods
Practice AP Computer Science A Unit 1 with targeted tests on primitive types, objects, String methods, Math class, casting, and wrapper classes in Java.
What Unit 1 Covers in AP Computer Science A
Unit 1 establishes the Java foundation that every other AP CSA topic builds on. Before you can write classes or traverse arrays, you must understand how Java handles data and how programs call methods. This unit covers the core building blocks of every Java program.
Primitive Types and Variables
Java distinguishes between primitive types — int, double, and boolean — and reference types. Understanding how each stores data, how arithmetic works, and how integer division behaves differently from double division is essential for tracing AP MCQ code correctly.
Objects and Method Calls
Objects are instances of classes. Unit 1 introduces how to create objects using constructors and how to call instance methods on them. The AP exam frequently presents short code segments where you must trace a sequence of method calls and determine the resulting output.
The String Class
String is one of the most commonly tested classes on the AP exam. Key methods include length(), substring(), indexOf(), equals(), and compareTo(). Many MCQ questions test whether you understand that Strings are immutable and that == does not compare String content.
The Math Class
The Math class provides static methods used throughout the AP exam — particularly Math.abs(), Math.pow(), Math.sqrt(), and Math.random(). Understanding how to read and use static method calls is a key MCQ skill.
Casting and Wrapper Classes
Type casting between int and double is a frequent source of AP MCQ traps. Wrapper classes such as Integer and Double allow primitives to be used where objects are required, particularly with ArrayLists in later units.
Common Mistakes on AP CSA Unit 1 Questions
- Type casting errors: Integer division truncates rather than rounds — (int)(7/2) produces 3, not 3.5.
- Null reference issues: Calling a method on an uninitialized object reference causes a NullPointerException.
- String comparison with ==: Using == instead of .equals() to compare String values is a classic AP trap.
- Immutability misunderstanding: String methods return new Strings — they do not modify the original.
AP MCQ Skills Developed in Unit 1
Unit 1 MCQ practice builds your ability to trace object creation, follow method call chains, and predict output for programs involving String manipulation and Math calculations. These tracing skills are foundational for every subsequent unit.