Multiple choice technology programming languages

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

  1. Compile time error at line 3

  2. Compile time error at line 4

  3. 5

  4. None

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

Line 3 is valid: (int)2.12 casts double to int (truncates to 2), then implicit narrowing to byte works. Line 4 fails: b + 3 promotes byte to int, result is int, cannot assign int to byte without cast. b = (byte)(b + 3) would fix it.