Multiple choice

Which of the following type conversions requires an explicit type cast?

  1. int to double

  2. int to String

  3. double to int

  4. double to String

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

Converting a double to an int is a narrowing conversion because it can result in a loss of precision as the fractional part is truncated. Therefore, Java requires an explicit cast, such as (int) myDouble, to confirm this conversion.