KnowledgeBoat Logo
|

Computer Applications

Assertion (A): The result of the Java expression 3 + 7/2 is 6.

Reason (R): According to the hierarchy of operators in Java, addition is done first followed by division.

  1. (A) is true and (R) is false.
  2. (A) is false and (R) is true.
  3. Both (A) and (R) are true and (R) is a correct explanation of (A).
  4. Both (A) and (R) are true and (R) is not a correct explanation of (A).

Java Operators

2 Likes

Answer

(A) is true and (R) is false.

Reason — In the expression 3 + 7/2, division has higher precedence than addition, so 7/2 is evaluated first using integer division, giving 3, and then added to 3 → 3 + 3 = 6, so Assertion (A) is true. However, the Reason (R) is incorrect because it wrongly states that addition is performed before division, which is not true in Java operator precedence.

Answered By

1 Like


Related Questions