Multiple choice technology programming languages

What will be the output of following code? 1 public class Main { 2 public static void main(String[] args) { 3 float b = 2.12; 4 b = b + 3.10; 5 System.out.println(b); 6 } 7 }

  1. Compile time error at line 3

  2. Compile time error at line 4

  3. 5.22

  4. None of above

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

The literal 2.12 is a double in Java. Assigning a double to float variable without cast or f suffix causes compile-time error. Should be 2.12f or (float)2.12.