sonalihande81
Test por , creado hace más de 1 año

Java SCJP Collection 1

78
1
0
sonalihande81
Creado por sonalihande81 hace casi 9 años
Cerrar

Java SCJP Collection 1

Pregunta 1 de 15

1

Which collection class(es) allows you to grow or shrink its size and provides indexed access to
its elements, but whose methods are not synchronized? (Choose all that apply.)

Selecciona una de las siguientes respuestas posibles:

  • java.util.HashSet

  • java.util.List

  • java.util.ArrayList

  • java.util.Vector

  • java.util.PriorityQueue

  • java.util.LinkedHashSet

Explicación

Pregunta 2 de 15

1

Which one of the following is true about natual order and insertion order ?

Selecciona una o más de las siguientes respuestas posibles:

  • insertion order means that the order in which the items are inserted into the collection

  • insertion order is determined by seeing if the element is inserted into the collection by using the insert() or add().

  • Natural order is different from insertion order is that the order incase of natural is determined by observing the data in the object in context

  • Natural order is not same as insertion order

Explicación

Pregunta 3 de 15

1

Wchich implementation of Set would you choose if the you want the iterator of set would geive you objects in the order it were inserted ?

Selecciona una de las siguientes respuestas posibles:

  • LinkedHashSet

  • TreeSet

  • HashSet

Explicación

Pregunta 4 de 15

1

What is the data structure that a Set uses to store its elements ?

Selecciona una de las siguientes respuestas posibles:

  • array

  • object

  • Map

  • ArrayList

Explicación

Pregunta 5 de 15

1

Set allows at most one null element ?

Selecciona una de las siguientes respuestas posibles:

  • True

  • False

Explicación

Pregunta 6 de 15

1

If you were to use a List implementation,but not sure which one to, bacause the requirement is not yet clear. In this case which List implementation will you use ?

Selecciona una de las siguientes respuestas posibles:

  • ArrayList

  • Vector

  • LinkedList

Explicación

Pregunta 7 de 15

1

If you were to store objects into an implementation of List which happens only once in the entire lifecycle of the product,but reading these objects inside the List implementation is quite high,then which one would you use ?

Selecciona una de las siguientes respuestas posibles:

  • Vector

  • LinkedList

  • ArrayList

Explicación

Pregunta 8 de 15

1

Which of the following implementation will you use if you were to insert elements at any position in the collection ?

Selecciona una de las siguientes respuestas posibles:

  • ArrayList

  • LinkedList

  • Vector

Explicación

Pregunta 9 de 15

1

The EMPTY_LIST field and teh emptyList() method does return an empty immutable List .(The same also applies to
EMPTY_SET,EMPTY_MAP and corresponding methods emptySet,emptyMap). Which of the following is/are true ?

Selecciona una o más de las siguientes respuestas posibles:

  • There is no difference between the field and emptyList() ways to fetch an empty immutable list

  • The field gives you a non type-safe empty immutable object where are the method return type-safe empty immutable object of collection

  • The method to get the empty immutable collections are not static, so we need to create an object of Collections class in-order to call these methods,so fields like EMPTY_XXX are better choice if one doesn't want to create object of Collections.

  • The emptyXxx() methods actually returns the EMPTY_XXX fields.

Explicación

Pregunta 10 de 15

1

Which of the following is true about creating an empty List, but immutable ?

Selecciona una o más de las siguientes respuestas posibles:

  • final List immutableEmptyList=new ArrayList();

  • List immutableEmptyList=Collections.unmodifiableList(new List());

  • List immutableEmptyList=Collections.EMPTY_LIST

  • List immutableEmptyList=Collections.unmodifiableList(new ArrayList());

Explicación

Pregunta 11 de 15

1

How do you get immutable object of a collection ? For example if you were to write an API which return a List or a Set or a Map when a method is called, but you also want that you don't want the client of your API to add or delete any object in the returned collection ?

Selecciona una de las siguientes respuestas posibles:

  • Use Collections.immutableCollection() method.

  • Use the Collections.unmodifiableXxxx() method with the collection as an argument,which returns an immutable object of specific type.

Explicación

Pregunta 12 de 15

1

Enumeration is an interface helps to iterate collection,but it can't remove any element the collection it is iterating

Selecciona una de las siguientes respuestas posibles:

  • True

  • False

Explicación

Pregunta 13 de 15

1

which of the following are false about Collections and Collection ?

Selecciona una de las siguientes respuestas posibles:

  • Collections is a utility class

  • Collection is an interface to Set and List

  • Collections is a special type of collection which holds Set of collections

  • Both Collections and Collection entity belongs to java.util package.

Explicación

Pregunta 14 de 15

1

Which of the following Collection are synchronized by nature ?

Selecciona una o más de las siguientes respuestas posibles:

  • Vector

  • SortedSet

  • Hashtable

  • HashMap

Explicación

Pregunta 15 de 15

1

Which of the following are true about ListIterator and Iterator ?

Selecciona una o más de las siguientes respuestas posibles:

  • Iterator can traverse in forward direction only

  • ListIterator can traverse lists in both direction

  • Iterator can do operations like modifying the items it holds.

  • ListIterator extends the Iterator interface

  • Iterator can remove the elements

Explicación