0% found this document useful (0 votes)
38 views

Test Your Understanding - Collection and Generics - Attempt Review

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Test Your Understanding - Collection and Generics - Attempt Review

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

 VIRAG NIMESHKUMAR DOSA…

 Dashboard / Programming using Java / Hands On - Collection, Generics and Stream API / Test Your Understanding - Collection and Generics

Started on Saturday, 22 May 2021, 3:53 PM


State Finished
Completed on Saturday, 22 May 2021, 4:00 PM
Time taken 6 mins 57 secs
Marks 6.00/6.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question
int[] myArray = new int[] {1, 2, 3, 4, 5};
1 What allows you to create a list from this array?
Correct

Mark 1.00 out of


1.00

Select one:
List myList = Collections.fromArray(myArray);

List myList = new ArrayList(myArray);

List myList = Arrays.asList(myArray); 

List myList = myArray.asList();

Your answer is correct.

The correct answer is: List myList = Arrays.asList(myArray);

Question
2 java.util.Map  interface provides the capability to store objects using a key-value pair ?

Correct

Mark 1.00 out of


1.00

Your answer is correct.

The correct answer is:


[java.util.Map ] interface provides the capability to store objects using a key-value pair ?
 VIRAG NIMESHKUMAR DOSA…

Question
Which two statements are true about the hashCode method?
3
Correct

Mark 1.00 out of Select one or more:


1.00
The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for
swift retrieval. 

The hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class. 

The hashCode method is used by the java.util.SortedSet collection class to order the elements within that set.

The only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a
Gaussian distribution.

Your answer is correct.

The correct answers are: The hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that
class., The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for
swift retrieval.

Question
Given:
4 11. public class Person {
Correct
12. private String name;
Mark 1.00 out of
1.00 13. public Person(String name) {

14. this.name = name;

15. }

16. public int hashCode() {

17. return 420;

18. }

19. }

Which statement is true?

Select one:
The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.

The time to nd the value from HashMap with a Person key depends on the size of the map. 

Inserting a second Person object into a HashSet will cause the rst Person object to be removed as a duplicate.

Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.

Your answer is correct.

The correct answer is: The time to nd the value from HashMap with a Person key depends on the size of the map.
 VIRAG NIMESHKUMAR DOSA…

Question
Given
5 1. import java.util.*;
Correct
2. public class WrappedString {
Mark 1.00 out of
1.00 3. private String s;

4. public WrappedString(String s) { this.s = s; }

5. public static void main(String[] args) {

6. HashSet<Object> hs = new HashSet<Object>();

7. WrappedString ws1 = new WrappedString("aardvark");

8. WrappedString ws2 = new WrappedString("aardvark");

9. String s1 = new String("aardvark");

10. String s2 = new String("aardvark");

11. hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);

12. System.out.println(hs.size()); } }

What is the result?

Select one:
3

Your answer is correct.

The correct answer is: 3

Question
6 nextIndex() and previousIndex() are methods of ListIterator  interface

Correct

Mark 1.00 out of


1.00

Your answer is correct.

The correct answer is:

nextIndex() and previousIndex() are methods of [ListIterator ] interface

You might also like