Menu
Question Index
...

What will be the ouput of the following program?

public class Marks {
    public static void main(String s[]) {
        boolean[] s1 = new boolean[4];
        boolean[] s2 = {true, false, true, false};
        System.out.print((s1[0] == s2[0]) + " ");
        System.out.print(s1[1] == s2[1]);
        int i = 0;
        System.out.println();
        for (Boolean b : s2) {
            while (b.equals(s1[i])) {
                System.out.print(s2.equals(s1) + " ");
                i++;
            }
        }
    }
}


false true
false false false false
false false
false false
false true
true false true false
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java equals method vs == Operator

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App