Multiple choice technology programming languages

Consider the following declarations ... float f = 4.5; //1 double d = 9.22; //2 short s = 3; //3 char c = s; //4 Which lines will throw error if any?

  1. 1 and 4

  2. 1

  3. 2 and 3

  4. 3 and 4

  5. no error

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

Line 1 fails because a double literal (4.5) cannot be implicitly assigned to a float without an 'f' suffix. Line 4 fails because a short cannot be implicitly assigned to a char due to range differences.