1/22
Flashcards covering key Java concepts, syntax rules, data types, Scanner input, arithmetic expressions, modulus, casting, and error types from AP CSA Unit 1.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is the difference between an IDE and a console in Java?
An IDE (Integrated Development Environment) is where you write your code, while the console is where the program displays output.

In Java programming, what are the primary purposes of each symbol shown in the table?
{ } is for code blocks, [ ] is for arrays, ( ) is for methods/method calls, // is for line comments, and ; is for end of statement.
Where does a Java program start executing?
Execution begins in the main method.
What is a syntax error in Java and when is it detected?
A syntax error breaks Java's rules (such as a missing semicolon or bracket) and is caught by the compiler before the program runs.
What is a logic error in Java?
An error where the program runs successfully but produces the wrong result, such as an incorrect calculation or loop boundary.
What is a runtime error and what is an Exception in Java?
A runtime error causes the program to crash while running; an Exception is a specific type of runtime error.
What rules must be followed when naming a Java identifier?
It can contain letters, digits, _, and $; it cannot start with a digit; it cannot be a reserved keyword; and it is case-sensitive.

According to the Java data types reference table shown, what does each data type store and what is an example of each?
int stores whole numbers (e.g., 5); double stores decimal numbers (e.g., 3.9); boolean stores true or false (e.g., true); String stores text (e.g., "Hello").
How do declaration, assignment, and initialization differ in Java?
Declaration creates the variable; assignment gives it a value; initialization performs both declaration and assignment in a single line.
In a Java assignment statement, where must the variable and value be positioned relative to the = operator?
The variable must go on the left of the = operator and the value must go on the right (e.g., number = 5;).
What is the difference between System.out.print() and System.out.println()?
System.out.print() prints output and stays on the same line, whereas System.out.println() prints output and moves to the next line.
What are the 3 steps required to set up and use Scanner for keyboard input in Java?
What is the result of the integer division expression 9/2 in Java?
4 (Java drops the decimal portion).
How does Java evaluate arithmetic expressions containing both an int and a double?
Java temporarily promotes the int to a double before performing the calculation.
What is the output of "Answer: " + 3 + 4 versus "Answer: " + (3 + 4)?
"Answer: 34" versus "Answer: 7".
What exception and error type occurs when dividing by zero in Java integer division (e.g., 5/0)?
It compiles successfully but causes a runtime error, specifically an ArithmeticException, causing the program to crash.
What does the modulus operator % calculate in Java?
It calculates the remainder after integer division (e.g., 7%2 evaluates to 1).
How can the modulus operator % be used to check if a number is even or odd?
number % 2 == 0 evaluates to true for even numbers, while number % 2 != 0 evaluates to true for odd numbers.
What happens if an int variable in Java goes beyond its minimum or maximum range?
Integer overflow occurs, causing Java to wrap around from the maximum value (Integer.MAX_VALUE) to the minimum value (Integer.MIN_VALUE) instead of throwing an exception.
What is the difference between widening and narrowing conversions in Java casting?
Widening converts a smaller type to a larger type (e.g., int to double) automatically; narrowing converts a larger type to a smaller type (e.g., double to int) and requires an explicit cast.
What is the result of casting (int)3.99 in Java?
3 (casting to int truncates or removes the decimal portion; it does NOT round).
What is the difference in output between double x = 7 / 2; and double x = (double)7 / 2;?
double x = 7 / 2; results in 3.0 because integer division occurs before storing, whereas double x = (double)7 / 2; results in 3.5 because casting occurs before division.
What Java expression is used to round a positive decimal value to the nearest integer?
(int)(value+0.5)