Menu
Question Index
...

What will be the output of the following program?

public class Operation {

    public static void main(String[] args) {
        int num1 = 0;
        int num2 = 0;
        for (int i = 0; i < 5; i++) {
            if ((++num1 > 2) && (++num2 > 2)) {
                num1++;
            }
        }
        System.out.println(num1 + " and " + num2);
        System.out.println(num2 | 12);
    }
}


5 and 2
14
5 and 3
15
6 and 3
15
6 and 4
12
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