Menu
Question Index
...

What will be the output of the following program?

class ForTest
{
    public static void main(String[] args)
    {
        for (char i = 'A'; i <= 'G'; i++)
        {
            if (i % 5 == 0)
            {
                System.out.print((char) (i - 'A' + 'a'));
            }
            else if (i % 2 == 0)
            {
                System.out.print((int) i);
            }
            else
            {
                System.out.print(i);
            }
            System.out.print('~');
        }
    }
}


A~98~C~100~E~F~G~
65~b~C~d~E~70~G~
97~B~C~D~E~102~G~
a~66~C~68~E~f~G~
b~B~C~D~E~g~G~
Compilation Error

Doubts

Problems

Topic: for Loop 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