Multiple choice technology programming languages

Following code will result in: int a = 3.5;

  1. Compilation error

  2. Runtime error

  3. a being 3.5

  4. a being 3

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

In Java, 3.5 is a double literal. Assigning a double value to an int variable without explicit casting causes a compilation error because of potential loss of precision. Java requires explicit type conversion like int a = (int)3.5;