Menu
Question Index
...

What will be the output of the following program?

class BoolArray {
    boolean[] bool = new boolean[3];
    int count = 0;
    void set(boolean[] x, int i) {
        x[i] = true;    ++count;
    }
    public static void main(String[] args) {
        BoolArray result = new BoolArray();
        result.set(result.bool, 0);
        result.set(result.bool, 2);
        result.check();
    }
    void check() {
        if (bool[0] && bool[1] | bool[2])
            count++;
        if (bool[1] && bool[(++count - 2)])
            count += 7;
        System.out.println("count = " + count);
    }
}


count = 0
count = 2
count = 3
count = 7
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App