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);
}
}A. {0, 1}
B. {2, 4}
C. {3, 4}
D. {3, 4, 5}
Select an option to see the answer and solution.
What are the use of front and rear pointers in CircularQueue implementation?
A. Front pointer points to first element; rear pointer points to the last element
B. Rear pointer points to first element; front pointer points to the last element
C. Front and read pointers point to the first element
D. Front pointer points to the first element; rear pointer points to null object
Select an option to see the answer and solution.
Which of the below is not a subinterface of Queue?
A. BlockingQueue
B. BlockingEnque
C. TransferQueue
D. None of These
Select an option to see the answer and solution.
Which of these method is used to reduce the capacity of an ArrayList object?
A. trim()
B. trimSize()
C. trimTosize()
D. trimToSize()
Select an option to see the answer and solution.
How to sort elements of ArrayList?
A. Collection.sort(listObj);
B. Collections.sort(listObj);
C. listObj.sort();
D. Sorter.sortAsc(listObj);
Select an option to see the answer and solution.
Which of these packages contain all the collection classes?
A. java.lang
B. java.util
C. java.net
D. java.awt
Select an option to see the answer and solution.
Which of these methods can be used to obtain set of all keys in a map?
A. getAll()
B. getKeys()
C. keyall()
D. keySet()
Select an option to see the answer and solution.
Which of these methods are member of Remote class?
A. checkIP()
B. addLocation()
C. AddServer()
D. None of the mentioned
Select an option to see the answer and solution.
Which of these method Map class is used to obtain an element in the map having specified key?
A. search()
B. get()
C. set()
D. look()
Select an option to see the answer and solution.
What is the name of a data member of class Vector which is used to store a number of elements in the vector?
A. length
B. elements
C. elementCount
D. capacity
Select an option to see the answer and solution.
What will be the output of the following Java program?
import java.util.*;
class Maps
{
public static void main(String args[])
{
HashMap obj = new HashMap();
obj.put("A", new Integer(1));
obj.put("B", new Integer(2));
obj.put("C", new Integer(3));
System.out.println(obj.keySet());
}
}A. [A, B, C]
B. {A, B, C}
C. {1, 2, 3}
D. [1, 2, 3]
Select an option to see the answer and solution.
What will be the output of the following Java code?
import java.util.*;
class date
{
public static void main(String args[])
{
Date obj = new Date();
System.out.print(obj);
}
}A. Prints Present Date
B. Runtime Error
C. Any Garbage Value
D. Prints Present Time & Date
Select an option to see the answer and solution.
What is the worst case complexity of accessing an element in ArrayList?
A. O(n)
B. O(1)
C. O(nlogn)
D. O(2)
Select an option to see the answer and solution.
What is the length of the application box made in the following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
Graphic g;
g.drawString("A Simple Applet",20,20);
}A. 20
B. Default value
C. Compilation Error
D. Runtime Error
Select an option to see the answer and solution.
If large number of items are stored in hash bucket, what happens to the internal structure?
A. The bucket will switch from LinkedList to BalancedTree
B. The bucket will increase its size by a factor of load size defined
C. The LinkedList will be replaced by another hashmap
D. Any further addition throws Overflow exception
Select an option to see the answer and solution.
Which of these standard collection classes implements a dynamic array?
A. AbstractList
B. LinkedList
C. ArrayList
D. AbstractSet
Select an option to see the answer and solution.
What is the default clone of HashSet?
A. Deep clone
B. Shallow clone
C. Plain clone
D. Hollow clone
Select an option to see the answer and solution.
What is the correct method used to insert and delete items from the queue?
A. push and pop
B. enqueue and dequeue
C. enqueue and peek
D. add and remove
Select an option to see the answer and solution.
Which of these standard collection classes implements all the standard functions on list data structure?
A. Array
B. LinkedList
C. HashSet
D. AbstractSet
Select an option to see the answer and solution.
What happens if two threads simultaneously modify TreeSet?
A. ConcurrentModificationException is thrown
B. Both threads can perform action successfully
C. FailFastException is thrown
D. IteratorModificationException is thrown
Select an option to see the answer and solution.