Q5
What is the result of the expression 10 / 3 in Java?
A.
3.3333
B.
3
AnswerC.
3.1
D.
4
Answer: Option B
Solution
Answer: Option B
Solution:
In Java, both 10 and 3 are integer values.When an arithmetic operation is performed between two integers, Java uses integer division.
Integer division discards the fractional (decimal) part of the result instead of rounding it.
So, the expression 10 / 3 evaluates to 3, not 3.3333 or 3.1.