AP Computer Science Array Practice Problem

The AP Computer Science A exam likes to ask questions along the lines of this code pictured below:

AP-Java-Array-question
What does this code do to the array?

Download Code

The question is,.. what does the “mystery” method do to that input array ?…. What is the output ?

 

And the answer is… Scroll down a bit

 

 

 

 

 

Yes, this code does indeed successfully remove excludingMe from the array

 

 

Although this code does successfully remove all occurrences of excludingMe , the code is not very intuitive.  And that’s that the sort of code that you will need to be able to figure out when you tackle some AP A computer science multiple choice questions.  A more intuitive way to remove elements from an array is covered in this post.