Expressions and Output() - AP Computer Science A
Card 1 of 30
What is the result of: System.out.println(10 / 3);?
What is the result of: System.out.println(10 / 3);?
Tap to reveal answer
- Integer division truncates the decimal portion in Java.
- Integer division truncates the decimal portion in Java.
← Didn't Know|Knew It →
What is the result of: System.out.println(10 / 3);?
What is the result of: System.out.println(10 / 3);?
Tap to reveal answer
- Integer division truncates the decimal portion in Java.
- Integer division truncates the decimal portion in Java.
← Didn't Know|Knew It →
What is the output of: System.out.println(8 / 3.0);?
What is the output of: System.out.println(8 / 3.0);?
Tap to reveal answer
2.6666666666666665. Double division produces precise floating-point result.
2.6666666666666665. Double division produces precise floating-point result.
← Didn't Know|Knew It →
What will be printed: System.out.println('2' + 3 + 4);?
What will be printed: System.out.println('2' + 3 + 4);?
Tap to reveal answer
- Character '2' concatenates, then numeric addition occurs.
- Character '2' concatenates, then numeric addition occurs.
← Didn't Know|Knew It →
What is the result of: System.out.println('a' + 1);?
What is the result of: System.out.println('a' + 1);?
Tap to reveal answer
- Character 'a' has ASCII value 97, so $97 + 1 = 98$.
- Character 'a' has ASCII value 97, so $97 + 1 = 98$.
← Didn't Know|Knew It →
What is the output of: System.out.println(4 + 2 * 3 - 1);?
What is the output of: System.out.println(4 + 2 * 3 - 1);?
Tap to reveal answer
- Order: $2 \times 3 = 6$, then $4 + 6 - 1 = 9$.
- Order: $2 \times 3 = 6$, then $4 + 6 - 1 = 9$.
← Didn't Know|Knew It →
How do you print a double quote in a string in Java?
How do you print a double quote in a string in Java?
Tap to reveal answer
Using escape sequence ". Backslash escapes special characters in string literals.
Using escape sequence ". Backslash escapes special characters in string literals.
← Didn't Know|Knew It →
What is the result of: System.out.println(6.0 / 3);?
What is the result of: System.out.println(6.0 / 3);?
Tap to reveal answer
2.0. Double dividend produces floating-point division.
2.0. Double dividend produces floating-point division.
← Didn't Know|Knew It →
What will be printed: System.out.println('a' + 'b');?
What will be printed: System.out.println('a' + 'b');?
Tap to reveal answer
- ASCII values: a=97, b=98, so $97 + 98 = 195$.
- ASCII values: a=97, b=98, so $97 + 98 = 195$.
← Didn't Know|Knew It →
What is the result of: System.out.println(12 / 5);?
What is the result of: System.out.println(12 / 5);?
Tap to reveal answer
- Integer division truncates the decimal portion.
- Integer division truncates the decimal portion.
← Didn't Know|Knew It →
Identify the error: System.out.println('Hello' - 'World');
Identify the error: System.out.println('Hello' - 'World');
Tap to reveal answer
Operator '-' cannot be applied to Strings. Subtraction operator is not defined for String operands.
Operator '-' cannot be applied to Strings. Subtraction operator is not defined for String operands.
← Didn't Know|Knew It →
What is the output of: System.out.println(0.1 + 0.2 == 0.3);?
What is the output of: System.out.println(0.1 + 0.2 == 0.3);?
Tap to reveal answer
false. Floating-point arithmetic precision issues cause inequality.
false. Floating-point arithmetic precision issues cause inequality.
← Didn't Know|Knew It →
What is the result of 10 % 3 in Java?
What is the result of 10 % 3 in Java?
Tap to reveal answer
- Modulus operator returns the remainder after division.
- Modulus operator returns the remainder after division.
← Didn't Know|Knew It →
What is the result of: System.out.println('Java' + 1 + 2);?
What is the result of: System.out.println('Java' + 1 + 2);?
Tap to reveal answer
Java12. String concatenation evaluates left-to-right without grouping.
Java12. String concatenation evaluates left-to-right without grouping.
← Didn't Know|Knew It →
What is the output of: System.out.println(5 + 2 * 3);?
What is the output of: System.out.println(5 + 2 * 3);?
Tap to reveal answer
- Multiplication precedence: $2 \times 3 = 6$, then $5 + 6 = 11$.
- Multiplication precedence: $2 \times 3 = 6$, then $5 + 6 = 11$.
← Didn't Know|Knew It →
What is the output of: System.out.println(9 / 2.0);?
What is the output of: System.out.println(9 / 2.0);?
Tap to reveal answer
4.5. Double divisor produces floating-point division result.
4.5. Double divisor produces floating-point division result.
← Didn't Know|Knew It →
What does the expression 2 * (3 + 4) evaluate to?
What does the expression 2 * (3 + 4) evaluate to?
Tap to reveal answer
- Parentheses force addition first: $(3 + 4) = 7$, then $2 \times 7 = 14$.
- Parentheses force addition first: $(3 + 4) = 7$, then $2 \times 7 = 14$.
← Didn't Know|Knew It →
What is the result of: System.out.println(4 * 0.5);?
What is the result of: System.out.println(4 * 0.5);?
Tap to reveal answer
2.0. Integer multiplied by double results in double type.
2.0. Integer multiplied by double results in double type.
← Didn't Know|Knew It →
Which data type can store a single character in Java?
Which data type can store a single character in Java?
Tap to reveal answer
char. Stores a single Unicode character in 16 bits.
char. Stores a single Unicode character in 16 bits.
← Didn't Know|Knew It →
What is the output of: System.out.println(8 / 3.0);?
What is the output of: System.out.println(8 / 3.0);?
Tap to reveal answer
2.6666666666666665. Double division produces precise floating-point result.
2.6666666666666665. Double division produces precise floating-point result.
← Didn't Know|Knew It →
What is the result of: System.out.println(6.0 / 3);?
What is the result of: System.out.println(6.0 / 3);?
Tap to reveal answer
2.0. Double dividend produces floating-point division.
2.0. Double dividend produces floating-point division.
← Didn't Know|Knew It →
What is the value of a boolean expression: 5 > 3 && 3 > 5?
What is the value of a boolean expression: 5 > 3 && 3 > 5?
Tap to reveal answer
false. Second condition is false, making the entire AND expression false.
false. Second condition is false, making the entire AND expression false.
← Didn't Know|Knew It →
Identify the error: System.out.println('Hello' - 'World');
Identify the error: System.out.println('Hello' - 'World');
Tap to reveal answer
Operator '-' cannot be applied to Strings. Subtraction operator is not defined for String operands.
Operator '-' cannot be applied to Strings. Subtraction operator is not defined for String operands.
← Didn't Know|Knew It →
What is the output of: System.out.println(3.0 / 2);?
What is the output of: System.out.println(3.0 / 2);?
Tap to reveal answer
1.5. Double division produces a floating-point result.
1.5. Double division produces a floating-point result.
← Didn't Know|Knew It →
Identify the error: System.out.println('Sum: ' + 5 + 3);
Identify the error: System.out.println('Sum: ' + 5 + 3);
Tap to reveal answer
Output is 'Sum: 53', not 'Sum: 8'. String concatenation with $+$ operator evaluates left-to-right without parentheses.
Output is 'Sum: 53', not 'Sum: 8'. String concatenation with $+$ operator evaluates left-to-right without parentheses.
← Didn't Know|Knew It →
Which data type can store a single character in Java?
Which data type can store a single character in Java?
Tap to reveal answer
char. Stores a single Unicode character in 16 bits.
char. Stores a single Unicode character in 16 bits.
← Didn't Know|Knew It →
What does the expression 2 + 3 * 4 evaluate to?
What does the expression 2 + 3 * 4 evaluate to?
Tap to reveal answer
- Multiplication precedence: $3 \times 4 = 12$, then $2 + 12 = 14$.
- Multiplication precedence: $3 \times 4 = 12$, then $2 + 12 = 14$.
← Didn't Know|Knew It →
What is the output of: System.out.println(0.1 + 0.2 == 0.3);?
What is the output of: System.out.println(0.1 + 0.2 == 0.3);?
Tap to reveal answer
false. Floating-point arithmetic precision issues cause inequality.
false. Floating-point arithmetic precision issues cause inequality.
← Didn't Know|Knew It →
What is the result of: System.out.println(12 / 5);?
What is the result of: System.out.println(12 / 5);?
Tap to reveal answer
- Integer division truncates the decimal portion.
- Integer division truncates the decimal portion.
← Didn't Know|Knew It →
What is the result of: System.out.println(4 * 0.5);?
What is the result of: System.out.println(4 * 0.5);?
Tap to reveal answer
2.0. Integer multiplied by double results in double type.
2.0. Integer multiplied by double results in double type.
← Didn't Know|Knew It →