๐Ÿ“– Crammy ยท All study guides
AP Computer Science A ยท Unit 1

Primitives: every key term you need

17 flashcard terms for AP Computer Science A Unit 1, written to match the course framework. Study them here, then drill them as interactive flashcards โ€” free, no account needed.

Study this unit free โ†’
Java Primitives
Basic data types: int, double, boolean, char. Store actual values (not references). Eight primitive types total.
int Type
32-bit integer; range โ‰ˆ -2 billion to +2 billion. Used for counting, indexing, calculations without decimals.
double Type
64-bit floating-point; represents decimal numbers. Used for precise calculations, measurements, divisions.
boolean Type
True or false; result of comparisons. Used in conditionals (if/else), loops. Single bit conceptually.
char Type
Single character: 'A', '5', '!'. Uses Unicode encoding. Enclosed in single quotes (different from String double quotes).
Type Casting
Convert between types: (int) 3.7 โ†’ 3 (truncates). (double) 5 โ†’ 5.0. Widening (small to large) safe; narrowing (large to small) risky.
Implicit Type Conversion
Java automatically widens types (int to double). Narrowing requires explicit cast. Math operations promote to larger type.
Arithmetic Operators
+ (add), - (subtract), * (multiply), / (divide), % (modulo/remainder). Precedence: *, /, % then +, -. Left-to-right for same precedence.
Modulo Operator %
Returns remainder: 7 % 3 = 1. Useful for: divisibility checks, cycling values, extracting digits.
Integer Division
5 / 2 = 2 (not 2.5) in Java. One or both operands must be double for decimal result: 5 / 2.0 = 2.5.
Variable Declaration
type name; or type name = value;. Example: int age; int age = 25;. Must declare before using.
Naming Conventions
Variables: camelCase starting lowercase. Constants: ALL_CAPS. Descriptive names improve readability.
Comparison Operators
== (equal), != (not equal), < (less), > (greater), <= (less/equal), >= (greater/equal). Return boolean.
Logical Operators
&& (AND), || (OR), ! (NOT). Used in compound conditions. Short-circuit: && stops if first false, || stops if first true.
Order of Operations
1. Parentheses, 2. Multiplication/Division/Modulo, 3. Addition/Subtraction, 4. Comparison, 5. Logical operators.
String Type (Not Primitive)
String class (capital S) for text. String s = \"Hello\"; Reference type, not primitive. Immutable.
Unit 1 Summary
Primitives: int, double, boolean, char. Casting converts types. Operators: arithmetic (+,-,*,/,%), comparison, logical. Variables store data.
Turn these into flashcards & quizzes โ†’

More AP Computer Science A guides