Back to Prep
apflashcard_set

AP CSA — Hard Java Logic & Edge Cases

Advanced flashcards targeting subtle Java behaviors, inheritance edge cases, and loop complexity patterns often found on the AP Exam.

20 cards

Preview

#1

Front

Integer Overflow & Wrapping

Back

Integer types (int) wrap around if they exceed their maximum value. Adding 1 to Integer.MAX_VALUE results in Integer.MIN_VALUE. Always check for bounds before arithmetic operations to prevent logical errors in counting loops.

#2

Front

Integer Division vs. Double Division

Back

In Java, division between two integers results in an integer (truncating the decimal). To retain decimal precision, at least one operand must be a double. Example: 5 / 2 evaluates to 2, while 5.0 / 2 evaluates to 2.5.

#3

Front

Postfix vs. Prefix Increment in Expressions

Back

Prefix (++x) increments the value before the expression is evaluated; Postfix (x++) uses the original value in the expression and increments afterward. Example: int x = 5; int y = x++; results in y being 5 and x becoming 6.

#4

Front

Short-Circuit Evaluation with && and ||

Back

Java evaluates logical operators from left to right and stops as soon as the result is determined. In (cond1 || cond2), if cond1 is true, cond2 is never evaluated. This prevents NullPointerExceptions if the second check depends on the first being true.

#5

Front

String Object Equality (== vs. .equals)

Back

The == operator compares references (memory addresses), while .equals() compares the actual content of the strings. Two String objects with the same characters will return false with == but true with .equals().

15 more cards in this deck

Sign up to access the full deck with spaced repetition review.

Sign Up — Free