Comp Sci AB question: Error in sample free response question?

<p>Well, it’s theoretically possible to do both with just one method, although it’s not too pretty. </p>

<p>For example, you could define transferNodesFromEnd( WaitingList other, int num ) so that if num is positive, the method proceeds as planned and num is added to the size of the current array. After that is done, you call the method again, this time using other.transferNodesFromEnd( this, -num ). Implement the method so that if num is negative, the size is decremented by that amount; also, if abs(num) equals size(), then set the value of front to null. Essentially, it’s a very messy way to utilize one method to do the job of two methods. I bet you were supposed to “assume” there were other methods like setNull() and setSize(), though.</p>

<p>Edit: never mind, the poster above me is correct. That would seem to defeat the entire purpose of encapsulation, but it’s right. [Controlling</a> Access to Members of a Class (The Java™ Tutorials > Learning the Java Language > Classes and Objects)](<a href=“JDK 24 Documentation - Home”>Controlling Access to Members of a Class (The Java™ Tutorials > Learning the Java Language > Classes and Objects))</p>