Question: Question 13 Assume that the following code has been executed (same for Questions 11 thru 14) : ArrayList nums = new ArrayList (); nums.add( 12
Question 13
Assume that the following code has been executed (same for Questions 11 thru 14):
ArrayListnums = new ArrayList (); nums.add( 12 ); nums.add( 32 ); nums.add( 15 ); nums.add( 2, 11 ); nums.add( 6 ); int s = nums.size(); int sum = 0; Iterator it = nums.iterator(); while( it.hasNext() ) { int n = it.next(); if ( n % 2 == 1 ) sum = sum + n; } nums.remove( 0 );
How many elements remain on the list when the code is finished executing?
| 4 |
| 1 |
| 6 |
| 7 |
| 5 |
Question 14
Assume that the following code has been executed (same for Questions 11 thru 14):
ArrayListnums = new ArrayList (); nums.add( 12 ); nums.add( 32 ); nums.add( 15 ); nums.add( 2, 11 ); nums.add( 6 ); int s = nums.size(); int sum = 0; Iterator it = nums.iterator(); while( it.hasNext() ) { int n = it.next(); if ( n % 2 == 1 ) sum = sum + n; } nums.remove( 0 );
What is the value of the first element remaining on the list?
| 11 |
| 6 |
| 15 |
| 12 |
| 32 |
Question 15
Which of the following is true about a HashMap?
| A HashMap is best thought of as a "lookup table." |
| Duplicate keys are not allowed in a HashMap. |
| A HashMap is an object. |
| All of the above |
Question 16
What can we say about the order in which entries are stored in a HashMap?
| Entries in the map are stored in the order of the calls to the put() method. |
| Entries are maintained in alphabetical or numerical order, by key. |
| There is no concept of 'order' at all for entries in a HashMap. If you iterate through the key set, the order in which keys are presented is unpredictable. |
| Entries are maintained in alphabetical or numerical order, by value. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
