In Java, what is the value of the expression 7 / 2 when both operands are of type int?
Please select an answer first.
Correct answer: A
The correct answer is 3.
- Trace the program or computing system: Identify the data, variables, objects, control flow, abstraction, network layer, or social impact described in the question.
- Apply the computer science principle: Integer division discards the fractional part, so 7 / 2 evaluates to 3.
- Check the result and assumptions: Check types, indexes, order of execution, boundary cases, representation, privacy, reliability, and whether the conclusion follows from the evidence.
Integer division discards the fractional part, so 7 / 2 evaluates to 3.
