Question: Consider the deleteFirst ( ) method of the ArrayedList class: public void deleteFirst ( ) { if ( isEmpty ( ) ) throw new RuntimeException

Consider the deleteFirst() method of the ArrayedList class:
public void deleteFirst(){
if (isEmpty())
throw new RuntimeException("Error: cannot delete an item from an empty list.");
for (int i=0; i this.listTail -1;i++){
}
this. listElements [i]= this.listElements i+1;
}
this.listTail--;
Further suppose that we define a specific exception for this method to throw instead of a generic RuntimeException:
public class ContainerFullException extends RuntimeException
public ContainerFullException(String message)
{
}
super(message);
public ContainerFullException()
{
}
super("ContainerFul1280Exception thrown!");
}
and then modify deleteFirst() to throw ContainerFullException instead of RuntimeException.
Which of the following conditions do we have to check for if we are testing the deleteFirst() method when the list is empty? (check all that apply)
Whether the method throws ContainerFullException()(a successful test)
Whether the method throws no exception (a failed test)
Whether the method throws a different exception (a failed test)
 Consider the deleteFirst() method of the ArrayedList class: public void deleteFirst(){

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!