Saturday, May 22, 2010

The following express char c = -1;?

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


b)will not cause a compiler error and c will have the value -1.


c)c will not represent any ASCII character.


d)c will still be a Unicode character.

The following express char c = -1;?
Will cause a compile error stating "possible loss of precision".


Type cast char like char c = (char) -1;


No comments:

Post a Comment