Collections
- Which of these class object can be used to form a dynamic array?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Vectors are dynamic arrays, it contains many legacy methods that are not part of collection framework, and hence these methods are not present in ArrayList. But both are used to form dynamic arrays.
- What is the output of this program?
import java.util.*;
public class Map_Example
{
public static void main(String args[])
{
HashMap object = new HashMap();
object.put("I", new Integer(9));
object.put("L", new Integer(12));
object.put("U", new Integer(21));
System.out.println(object.get("L"));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
object.get(“L”) method is used to obtain the value associated with key “L”, which is 12.
- What is the output of this program?
import java.util.*;
public class Map_Exmple
{
public static void main(String args[])
{
TreeMap object = new TreeMap();
object.put("I", new Integer(9));
object.put("L", new Integer(12));
object.put("U", new Integer(21));
System.out.println(object.entrySet());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
object.entrySet() method is used to obtain a set that contains the entries in the map. This method provides set view of the invoking map.
- Which of these methods can be used to delete the last element in a LinkedList object?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
removeLast() and removeFirst() methods are used to remove elements in end and beginning of a linked list.
- Which of these are legacy classes?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Stack, Hashtable, Vector, Properties and Dictionary are legacy classes.