Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)
1)Whether the method throws ContainerFullException()(a successful test)
2)Whether the method throws no exception (a failed test)
3)Whether the method throws a different exception (a failed test)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions