In the previous method insert, the second ifstatement tests the value of newPosition. Should the boolean expression it tests be isEmpty() || (newPosition == 1)? Explain.
What will be an ideal response?
Although you could test for an empty list, such a test is not necessary. When a list is empty, itemCount is zero. The only acceptable position for an insertion is 1, because the boolean expression (newPosition >= 1)&& (newPosition <= itemCount + 1) will be true. Therefore, the body of the first ifstatement will execute, and the insertion into the empty list will occur correctly.
You might also like to view...
The user provides the criterion at run time when using a lookup list
Indicate whether the statement is true or false
The ________ command is used when you want to save the entire notebook, a page, a group, or a section to a different location
Fill in the blank(s) with correct word
The VHD type that allocates all storage for the VHD during the time in which the hard disk is created is called a ________ disk
Fill in the blank(s) with correct word
COGNITIVE ASSESSMENT Many mobile computers and mobile devices use LCD monitors. What does LCD stand for?
A. large character display B. liquid crystal display C. large crystal design D. liquid color design