Multiple choice technology programming languages

Following code will result in: int a1 = 5; double a2 = (float)a1;

  1. Compilation error

  2. Runtime error

  3. No errors

  4. Compilation error at statement 2

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

This code performs a valid type conversion: an int is cast to float, then the float is assigned to a double. Both conversions are legal - the cast is explicit (int to float), and the float to double conversion is implicit widening. No compilation or runtime errors occur.