Multiple choice technology programming languages

int i=5; int a = + --i/2.0;

  1. Does not compile saying binary operator has invalid use

  2. 2.0

  3. 2.5

  4. exception will be thrown

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The expression evaluates as: pre-decrement --i changes i from 5 to 4, then 4/2.0 gives 2.0 (double division because 2.0 is double), and the unary + keeps it as 2.0. Note: The assignment 'int a = 2.0' would cause a compilation error due to type mismatch; the question focuses on the expression value.