Sequential conversions

Report a typo

The program below initializes an intValue variable and attempts to convert its value to char, short, and byte types one after another. Your task is to fill in the gaps with the correct type conversion operators to ensure the program compiles successfully.

Fill in the gaps with the relevant elements
public class Main {
    public static void main(String[] args) {
        int intValue = 128;
        char charValue =  intValue;
        short shortValue =  charValue;
        byte byteValue =  shortValue;

        System.out.println("Type conversion: " + intValue + "," + charValue + "," + shortValue + "," + byteValue);
    }
}

Create a free account to access the full topic