The find method, used by the remove, contains, and addAfter operations, returns -1 if an element is not found in an array based implementation of a list collection. Why doesn’t it throw an Exception in this case?

What will be an ideal response?

The find method is a private method that is used by public methods that provide the interface to the list
collection. By returning -1 as a signal that an element is not in the list, the calling method can determine how to respond. In the
case of the remove operation, the correct response is to throw an exception, as you cannot remove something that is not
present. In the case of the contains operation, the correct response is to return false to indicate that there is no such element in
the list.

Computer Science & Information Technology

You might also like to view...

________ recommends music to you based on your, and your friends, listening preferences

A) Picasa B) Pandora C) Flickr D) SnapDragon

Computer Science & Information Technology

Which of the following correctly accesses element 13 of array Book?

a) Book(0) + 13 b) Book(13) c) Book[13] d) None of the above.

Computer Science & Information Technology