Study Expressions And Output in AP Computer Science a with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.
All flashcards
Flashcard 1: What is the output of: System.out.println('A' + 1);?
Answer:
- Character 'A' has ASCII value 65, so 65+1=66.
Flashcard 2: What is the result of 10 % 3 in Java?
Answer:
- Modulus operator returns the remainder after division.
Flashcard 3: What does System.out.print() do differently than println()?
Answer: Output without a newline. Does not add a newline character after output.
Flashcard 4: Identify the error: System.out.println('Hello' - 'World');
Answer: Operator '-' cannot be applied to Strings. Subtraction operator is not defined for String operands.
Flashcard 5: What will be printed: System.out.println(true && false);?
Answer: false. Logical AND requires both operands to be true.
Flashcard 6: What is the operator precedence of *, /, %, +, - in Java?
Answer: *, /, % have higher precedence than +, -. Multiplication, division, and modulus are evaluated before addition and subtraction.
Flashcard 7: What is the output of: System.out.println(4 + 2 * 3 - 1);?
Answer:
- Order: 2×3=6, then 4+6−1=9.
Flashcard 8: What is the result of: System.out.println(10 % 2);?
Answer:
- 10 divided by 2 has no remainder.
Flashcard 9: How is a string concatenated with an integer in Java?
Answer: Using the + operator. The + operator performs concatenation when one operand is a string.
Flashcard 10: What will be printed: System.out.println('a' + 'b');?
Answer:
- ASCII values: a=97, b=98, so 97+98=195.
Flashcard 11: What is the output of: System.out.println(8 / 3.0);?
Answer: 2.6666666666666665. Double division produces precise floating-point result.
Flashcard 12: What does the expression 2 * (3 + 4) evaluate to?
Answer:
- Parentheses force addition first: (3+4)=7, then 2×7=14.
Flashcard 13: Identify the error: System.out.println('Sum: ' + 5 + 3);
Answer: Output is 'Sum: 53', not 'Sum: 8'. String concatenation with + operator evaluates left-to-right without parentheses.
Flashcard 14: How do you declare a constant in Java?
Answer: Using the final keyword. Makes variables immutable after initialization.
Flashcard 15: What is the result of: System.out.println(4 * 0.5);?
Answer: 2.0. Integer multiplied by double results in double type.
Flashcard 16: What is the output of: System.out.println(9 / 2.0);?
Answer: 4.5. Double divisor produces floating-point division result.
Flashcard 17: What is the operator used for modulus in Java?
Answer: %. Returns the remainder of integer division.
Flashcard 18: What is the result of: System.out.println(6.0 / 3);?
Answer: 2.0. Double dividend produces floating-point division.
Flashcard 19: What is the result of: System.out.println('a' + 1);?
Answer:
- Character 'a' has ASCII value 97, so 97+1=98.
Flashcard 20: What is the result of: System.out.println(12 / 5);?
Answer:
- Integer division truncates the decimal portion.
Flashcard 21: What does the '==' operator compare in Java?
Answer: Primitive values or object references. Compares actual values for primitives, memory addresses for objects.
Flashcard 22: What will be printed: System.out.println('2' + 3 + 4);?
Answer:
- Character '2' concatenates, then numeric addition occurs.
Flashcard 23: What is the output of: System.out.println('A' + 'B');?
Answer:
- ASCII values: A=65, B=66, so 65+66=131.
Flashcard 24: Identify the error: System.out.println('Hello' - 'World');
Answer: Operator '-' cannot be applied to Strings. Subtraction operator is not defined for String operands.
Flashcard 25: What is the result of: System.out.println('Java' + 1 + 2);?
Answer: Java12. String concatenation evaluates left-to-right without grouping.
Flashcard 26: What is the result of: System.out.println(7 - 3 * 2);?
Answer:
- Multiplication has higher precedence: 3×2=6, then 7−6=1.
Flashcard 27: What is the result of: System.out.println('a' + 1);?
Answer:
- Character 'a' has ASCII value 97, so 97+1=98.
Flashcard 28: Which data type can store a single character in Java?
Answer: char. Stores a single Unicode character in 16 bits.
Flashcard 29: What is the output of: System.out.println(0.1 + 0.2 == 0.3);?
Answer: false. Floating-point arithmetic precision issues cause inequality.
Flashcard 30: What is the result of 10 % 3 in Java?
Answer:
- Modulus operator returns the remainder after division.
Flashcard 31: What does System.out.print() do differently than println()?
Answer: Output without a newline. Does not add a newline character after output.
Flashcard 32: What is the output of: System.out.println(3.0 / 2);?
Answer: 1.5. Double division produces a floating-point result.
Flashcard 33: What is the result of: System.out.println(12 / 5);?
Answer:
- Integer division truncates the decimal portion.
Flashcard 34: What will be printed: System.out.println('2' + 3 + 4);?
Answer:
- Character '2' concatenates, then numeric addition occurs.
Flashcard 35: What is the output of: System.out.println(8 / 3.0);?
Answer: 2.6666666666666665. Double division produces precise floating-point result.
Flashcard 36: How is a string concatenated with an integer in Java?
Answer: Using the + operator. The + operator performs concatenation when one operand is a string.
Flashcard 37: What does the expression 2 * (3 + 4) evaluate to?
Answer:
- Parentheses force addition first: (3+4)=7, then 2×7=14.
Flashcard 38: What does the expression 2 + 3 * 4 evaluate to?
Answer:
- Multiplication precedence: 3×4=12, then 2+12=14.
Flashcard 39: What is the output of: System.out.println('A' + 1);?
Answer:
- Character 'A' has ASCII value 65, so 65+1=66.
Flashcard 40: What is the value of a boolean expression: 5 > 3 && 3 > 5?
Answer: false. Second condition is false, making the entire AND expression false.
Flashcard 41: What is the output of: System.out.println(5 + 2 * 3);?
Answer:
- Multiplication precedence: 2×3=6, then 5+6=11.
Flashcard 42: What will be printed: System.out.println(true && false);?
Answer: false. Logical AND requires both operands to be true.
Flashcard 43: What is the output of: System.out.println(4 + 2 * 3 - 1);?
Answer:
- Order: 2×3=6, then 4+6−1=9.
Flashcard 44: What is the output of: System.out.println(0.1 + 0.2 == 0.3);?
Answer: false. Floating-point arithmetic precision issues cause inequality.
Flashcard 45: What is the output of: System.out.println(3.0 / 2);?
Answer: 1.5. Double division produces a floating-point result.
Flashcard 46: How do you declare a constant in Java?
Answer: Using the final keyword. Makes variables immutable after initialization.
Flashcard 47: What is the result of: System.out.println('Java' + 1 + 2);?
Answer: Java12. String concatenation evaluates left-to-right without grouping.
Flashcard 48: What is the output of: System.out.println(5 + 2 * 3);?
Answer:
- Multiplication precedence: 2×3=6, then 5+6=11.
Flashcard 49: What is the result of: System.out.println(6.0 / 3);?
Answer: 2.0. Double dividend produces floating-point division.
Flashcard 50: What is the result of: System.out.println(10 % 2);?
Answer:
- 10 divided by 2 has no remainder.
Flashcard 51: What does the '==' operator compare in Java?
Answer: Primitive values or object references. Compares actual values for primitives, memory addresses for objects.
Flashcard 52: What does the expression 2 + 3 * 4 evaluate to?
Answer:
- Multiplication precedence: 3×4=12, then 2+12=14.
Flashcard 53: What is the result of: System.out.println(7 - 3 * 2);?
Answer:
- Multiplication has higher precedence: 3×2=6, then 7−6=1.
Flashcard 54: What does the expression 5 + 3 * 2 evaluate to in Java?
Answer:
- Multiplication has higher precedence than addition: 3×2=6, then 5+6=11.
Flashcard 55: Identify the error: System.out.println('Sum: ' + 5 + 3);
Answer: Output is 'Sum: 53', not 'Sum: 8'. String concatenation with + operator evaluates left-to-right without parentheses.
Flashcard 56: What is the result of: System.out.println(10 / 3);?
Answer:
- Integer division truncates the decimal portion in Java.
Flashcard 57: What is the output of: System.out.println('Java' + (1 + 2));?
Answer: Java3. Parentheses force addition first, then concatenation.
Flashcard 58: What is the result of: System.out.println(10 / 3);?
Answer:
- Integer division truncates the decimal portion in Java.
Flashcard 59: What is the output of: System.out.println(9 / 2.0);?
Answer: 4.5. Double divisor produces floating-point division result.
Flashcard 60: What is the result of: System.out.println(4 * 0.5);?
Answer: 2.0. Integer multiplied by double results in double type.
Flashcard 61: How do you print a double quote in a string in Java?
Answer: Using escape sequence ". Backslash escapes special characters in string literals.
Flashcard 62: What is the value of a boolean expression: 5 > 3 && 3 > 5?
Answer: false. Second condition is false, making the entire AND expression false.
Flashcard 63: What is the operator precedence of *, /, %, +, - in Java?
Answer: *, /, % have higher precedence than +, -. Multiplication, division, and modulus are evaluated before addition and subtraction.
Flashcard 64: What is the output of: System.out.println('A' + 'B');?
Answer:
- ASCII values: A=65, B=66, so 65+66=131.
Flashcard 65: What will be printed: System.out.println('a' + 'b');?
Answer:
- ASCII values: a=97, b=98, so 97+98=195.
Flashcard 66: What does the expression 5 + 3 * 2 evaluate to in Java?
Answer:
- Multiplication has higher precedence than addition: 3×2=6, then 5+6=11.
Flashcard 67: How do you print a double quote in a string in Java?
Answer: Using escape sequence ". Backslash escapes special characters in string literals.
Flashcard 68: Which data type can store a single character in Java?
Answer: char. Stores a single Unicode character in 16 bits.
Flashcard 69: What is the output of: System.out.println('Java' + (1 + 2));?
Answer: Java3. Parentheses force addition first, then concatenation.
Flashcard 70: What is the operator used for modulus in Java?
Answer: %. Returns the remainder of integer division.