Question: Question 11 Assume that the following code has been executed (same for Questions 11 thru 14) : ArrayList nums = new ArrayList (); nums.add( 12

Question 11

Assume that the following code has been executed (same for Questions 11 thru 14):

ArrayList nums = 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 variable 's'?

6
5
7
2
4

Question 12

Assume that the following code has been executed (same for Questions 11 thru 14):

ArrayList nums = 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 variable 'sum'?

78
26
76
50
15

Question 13

Assume that the following code has been executed (same for Questions 11 thru 14):

ArrayList nums = 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?

7
1
5
4
6

Question 14

Assume that the following code has been executed (same for Questions 11 thru 14):

ArrayList nums = 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?

12
11
15
32
6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!