Answer the questions and give explanation of each question. Collections 1) When
ID: 3593522 • Letter: A
Question
Answer the questions and give explanation of each question.
Collections
1) When a generic method is called, A) the compiler uses information explicitly specified by the programmer, if available; otherwise, the type defaults to Object B) the programmer must explicitly specify the actual types to use for the type parameters C) the compiler determines the actual types to use for the type parameters from the context D) None of the above
2) The three major categories of Java collections are A) lists, sets, and maps
B) tree sets, list sets, and hash mapsC) hash lists, hash tables, and sets
D) sets, collections, and maps
3) A Java collection
A) is an object that is is used as a container for other objectsB) is an abstract class in the java.collect packageC) is a class that is defined in the java.awt packageD) None of the above
4) A collection whose elements are pairs of keys and values is called
A) an enumerator B) a map C) a paired collection D) a hash list
5) A collection that does not impose a positional order on its elements, and does not allow duplicates is called a A) non-positional map B) hash map C) linked list D) set 6) A collection that stores its elements in an (ordered) sequence, and allows access to each element by its position in the sequence is called a A) positional map B) list C) map D) ordered set 7) Which of the following is true?
A) A set allows duplicate values to be storedB) A list allows duplicate values to be storedC) A map allows duplicate keys to be storedD) No Java collection allows duplicate values to be stored 8) An entry in a map
A) may not share a key value with any other entry in the mapB) is called a mappingC) associates a key with a valueD) All of the above
9)To compare two objects,
A) Use the ==, e.g. object1 == object2
B) Use an equals method to make a field by field comparison of the two objects
C) write a method to do a byte-by-byte compare of the two objects
D) Since objects consist of several fields, you cannot compare them.
10) What are some inefficiencies accomplished with a bad OOP design? Name at least two.
LinkedLists
In a linkedlist which node holds the first node value in the list?
a. Head
b. First
c. Tail
d. Null
e. A or B
2. As a data structure each node holds both a _____ and a ______.
a. Node,value
b. Node,list
c. Value,reference
d. Null, list
3. What type of data can nodes reference?
a. A singular value
b. An array
c. Any object
d. All of the above
4. The last link in a linked list must point to a ________ value?
Explanation / Answer
1- When a generic method is called the compiler determines the actual types to use for the type parameters from the context as
based on the types of the arguments passed to the generic method, the compiler handles each method call appropriately
2- The three major categories of Java collections are
Lists,sets and maps. as tree sets,list sets hash maps,hash lists,hash tables are a sub categories of list,set and maps
and collection is a categorized set of list ,set and maps in java.
3-A java collection is an object that is is used as a container for other objects as the defination says it is a framework
that represents a unified architecture for storing and manipulating a group of objects.
4-A collection whose elements are pairs of keys and values is called maps as maps are interface that maps unique key to values
in a collection.A key is an object that we use to retrieve a value later.
5-A collection that does not impose a positional order on its elements, and does not allow duplicates is called a set
a set has unordered values and it does not allow duplpicate values.
6-A collection that stores its elements in an (ordered) sequence, and allows access to each element by its position in the sequence is called a
list as list works just like an array it has an ordered sequence and we can access elements by its position.
7-A list allows duplicate values to be stored as in list duplicates are allowed set does not allows duplicate values to be stored.
8-An entry in a map associates a key with a value as in maps the values have a particular key by which they can be identified in a map.
9-to compare two objects we use Use an equals method to make a field by field comparison of the two objects as == just checks that two objects have same refference or not it is shallow comparision but equals method does deep comparision.
Linked list-
In a linkedlist which node holds the first node value in the list- Head in linked list the first node is always called as the
head as it is the starting node for the linked list.
2-As a data structure each node holds both a value and a reference. in linked list we have nodes and in node it contains
the value as well as an address to the next node which links the nodes in a linked list.
3-All of the above as a data value in a node can have a single value , an array or aan object..
4-The The last link in a linked list must point to a NULL value because in linked list the last node will not point to any other node so its
refference pointer will contain no address that is NULL value.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.