Multiple choice

Which of the following is/are the conditions for automatic type conversion? (a) The two types are compatible. (b) The destination type is lager than the source type. (c) The source type is lager than the destination type. When one type of data is assigned to another type of variable, an automatic type conversion takes place if some conditions are met.

  1. Only (a)

  2. Only (a) and (b)

  3. All (a), (b) and (c)

  4. Only (a) and (c)

  5. None of these

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

The two types are compatible. The destination type is lager than the source type. When these two conditions are met, a widening conversion takes place. For example, the int type is large enough to hold all valid byte values.