0
Alien head

Java Objects and Collections Quiz

Description: Java Objects and Collections Quiz
Number of Questions: 10
Created by:
Tags: java
Attempted 0/10 Correct 0 Score 0

Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?

  1. TreeMap

  2. HashMap

  3. LinkedHashMap

  4. The answer depends on the implementation of the existing instance.


Correct Option: C

Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

  1. java.lang.String

  2. java.lang.Double

  3. java.lang.StringBuffer

  4. java.lang.Character


Correct Option: C

Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

  1. java.util.HashSet

  2. java.util.LinkedHashSet

  3. java.util.List

  4. java.util.ArrayList


Correct Option: D

You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

  1. java.util.Map

  2. java.util.Set

  3. java.util.List

  4. java.util.Collection


Correct Option: B

Which interface does java.util.Hashtable implement?

  1. Java.util.Map

  2. Java.util.List

  3. Java.util.HashTable

  4. Java.util.Collection


Correct Option: A
Explanation:

Hash table based implementation of the Map interface.

Which interface provides the capability to store objects using a key-value pair?

  1. Java.util.Map

  2. Java.util.Set

  3. Java.util.List

  4. Java.util.Collection


Correct Option: A
Explanation:

An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

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?

  1. java.util.ArrayList

  2. java.util.LinkedHashMap

  3. java.util.HashMap

  4. java.util.TreeMap


Correct Option: B

Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?

  1. java.util.SortedMap

  2. java.util.TreeMap

  3. java.util.TreeSet

  4. java.util.Hashtable


Correct Option: D

Which is valid declaration of a float?

  1. float f = 1F;

  2. float f = 1.0;

  3. float f = "1";

  4. float f = 1.0d;


Correct Option: A

What is the numerical range of char?

  1. 0 to 32767

  2. 0 to 65535

  3. -256 to 255

  4. -32768 to 32767


Correct Option: B
+ View questions