Menu
Question Index
...

What will be the output of the following program?

public class Loops {
    public static void main(String args[]) {
        for (int i = 1; i <= 5; i++) {
            if (i % (3 * 5) == 0)
                System.out.print("Andhra" + ",");
            else if (i % 5 == 0)
                System.out.print("Pradesh" + ",");
            else if (i % 3 == 0)
                System.out.print("India" + ",");
            else
                System.out.println(i + ",");
        }
    }
}


1,2,India,4,
1,2,India,4,Pradesh,
Andhra,1,2,India,4,Pradesh,
Some other output
Compilation Error or Runtime 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