-
What is the output of this program?
import java.util.*;
public class Bitset_Example
{
public static void main(String args[])
{
BitSet object0 = new BitSet(12);
BitSet object1 = new BitSet(15);
for (int k = 0; k < 7; ++k)
{
object0.set(k);
}
for (int k = 3; k < 15; ++k)
{
object1.set(k);
}
object0.and(object1);
System.out.print(object0);
}
}
-
- {3, 4, 5}
- {4, 5, 6}
- {4, 5}
- {3, 4, 5, 6}
- None of these
Correct Option: D
object0.and(object1) returns an BitSet object which contains elements common to both the object object0 and object1 and stores this BitSet in invoking object that is object0. Hence object0 contains {3, 4, 5, 6}.