Multiple choice technology programming languages

The following expression……….char c = -1;

  1. will cause a compiler error as the range of character is between 0 and 2^16 - 1. Will request for an explicit cast.

  2. will not cause a compiler error and c will have the value -1;

  3. c will not represent any ASCII character.

  4. c will still be a Unicode character.

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

In Java, char is an unsigned 16-bit type with range 0 to 65535. Assigning -1 requires an explicit cast because -1 is outside this range. Without casting, the compiler will reject the assignment.