Collections Framework In Java - Study Mode

[#161] What will be the output of the following Java code? import java.util.*
class Bitset
{
public static void main(String args[])
{
BitSet obj1 = new BitSet(5)
BitSet obj2 = new BitSet(10)
for (int i = 0
i < 5
++i)
obj1.set(i)
for (int i = 3
i < 13
++i)
obj2.set(i)
obj1.and(obj2)
System.out.print(obj1)
}
}
Correct Answer

(C) {3, 4}

[#162] What are the use of front and rear pointers in CircularQueue implementation?
Correct Answer

(C) Front and read pointers point to the first element

[#163] How to sort elements of ArrayList?
Correct Answer

(B) Collections.sort(listObj)

[#164] What is the difference between TreeSet and SortedSet?
Correct Answer

(D) SortedSet is an interface TreeSet is a concrete class

[#165] What will be the output of the following Java code? import java.lang.reflect.*
class Additional_packages
{
public static void main(String args[])
{
try
{
Class c = Class.forName("java.awt.Dimension")
Field fields[] = c.getFields()
for (int i = 0
i < fields.length
i++)
System.out.println(fields[i])
}
catch (Exception e)
{
System.out.print("Exception")
}
}
}
Correct Answer

(C) Program prints all the data members of 'java.awt.Dimension' package