Question: If an array bag contains the entries A, B, C, C, D, E and a call to the remove method with the entry C is

If an array bag contains the entries A, B, C, C, D, E and a call to the remove method with the entry C is made, what does the array look like after this removal?

The remove method is shown below.

public boolean remove(T anEntry) {

for(int i=0; i

if(bag[i]==anEntry){

numberOfEntries--;

bag[i]=bag[numberOfEntries];

bag[numberOfEntries]=null;

return true;

}

}

return false;

}

A

A, B, C, D, E

B

A, B, E, C, D

C

A, B, D, E

D

A, B, E, D

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!