Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class BitsetTester {
    public static void main(String[] args) {
        BitSet b1 = new BitSet(10);
        b1.set(1);    b1.set(4);    b1.set(3);
        BitSet b2 = new BitSet(10);
        b2.set(4);    b2.set(5);    b2.set(3);
        System.out.print(b1 + ", ");
        System.out.println(b2);
        if (b1.equals(b2)) {    System.out.println("Equal");    }
        else {    System.out.println("Not Equal");    }
        BitSet clone = (BitSet) b1.clone();
        if (b1.equals(clone)) {    System.out.println("Equal");    }
        else {    System.out.println("Not Equal");    }
        b1.and(b2);
        System.out.println(b1);
    }
}


[4, 3, 1], [5, 4, 3]
Not Equal
Equal
[5, 4, 3]
{4, 3, 1}, {5, 4, 3}
Equal
Not Equal
{5, 4, 3}
[1, 3, 4], [3, 4, 5]
Not Equal
Equal
[1, 3, 4, 3, 4, 5]
{1, 3, 4}, {3, 4, 5}
Not Equal
Equal
{3, 4}
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java BitSet

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App