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.
You might also like to view...
A recurring task is a task that repeats at regular intervals
Indicate whether the statement is true or false
This system adds the capability to react to an attack detected by another component.
A. intrusion detection system (IDS) B. host-based IDS (HIDS) C. intrusion prevention system (IPS) D. network-based IDS (NIDS)
Apple TV and Roku are examples of a(n) ____.
A. Blue-Ray player B. game console C. apps D. set-top box
Jane, a user, has attempted to enter her username and password three times unsuccessfully. Jane receives a message to try again in one hour. This is an example of which of the following?
A. Account expiration B. Account recovery C. Account lockout D. Account disablement