Option B is incorrect because any literal number with a decimal point u declare the computer will implicitly cast to double unless you include "F or f"
Option C is incorrect because it is a String.
Option D is incorrect because "d" tells the computer it is a double so therefore you are trying to put a double value into a float variable i.e there might be a loss of precision.
Discuss About this Question.
Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?
A:
java.util.SortedMap
B:
java.util.TreeMap
C:
java.util.TreeSet
D:
java.util.Hashtable
Answer:D
Hashtable is the only class listed that provides synchronized methods. If you need synchronization great; otherwise, use HashMap, it's faster.
Discuss About this Question.
Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?
A:
java.util.ArrayList
B:
java.util.LinkedHashMap
C:
java.util.HashMap
D:
java.util.TreeMap
Answer:B
LinkedHashMap is the collection class used for caching purposes. FIFO is another way to indicate caching behavior. To retrieve LinkedHashMap elements in cached order, use the values() method and iterate over the resultant collection.
Discuss About this Question.
Which interface provides the capability to store objects using a key-value pair?
A:
Java.util.Map
B:
Java.util.Set
C:
Java.util.List
D:
Java.util.Collection
Answer:A
An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.
Discuss About this Question.
Which interface does java.util.Hashtable implement?
A:
Java.util.Map
B:
Java.util.List
C:
Java.util.HashTable
D:
Java.util.Collection
Answer:A
Hash table based implementation of the Map interface.
Discuss About this Question.
Ad Slot (Above Pagination)
Install ExamAdept
Fast access — add this app to your device.
To install on iPhone/iPad: tap Share → Add to Home Screen.
Discuss About this Question.