Multiple choice technology web technology

Which of these assignments are not valid?

  1. short s = 28

  2. byte b = 12

  3. float f = 2.3

  4. double d = 2.3

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

In Java, 2.3 is a double literal by default. Assigning it directly to a float without an f suffix or cast causes a compilation error because of potential precision loss. Option D (double d = 2.3) is valid.