Menu
Question Index
...

What will be the output of the following program?

class CharDemo
{
    public static void main(String args[])
    {
        char ch1 = 88; // 88 is character code of X
        char ch2 = 'Y'; // Y character code is 89
        
        int i1 = ch1;
        
        System.out.println("i1 = " + i1);
        System.out.println("ch1 = " + ch1);
        System.out.println("ch2 = " + ch2);
    }
}


i1 = 88
ch1 = X
ch2 = Y
i1 = X
ch1 = X
ch2 = Y
Compilation errors.
i1 = 88
ch1 = 88
ch2 = 89

Doubts

Problems

Topic: Type Conversion In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App