Originally posted by Abhi vijay:
How are byte and char compatible???
short and char are not compatible even though they have 16 bits data length???
Neither byte and char, nor short and char are compatible my friend.
Although you are right that they must be compatible as they occupy the same size of memory, but they are not compatible because char can't accept -ve values. So a byte can contain -20, char cannot have any negative value. This is why you cannot assign a byte(which occupies 1 byte) to a char (which occupies 2 bytes).