Question 2 1 pts public interface List f *Returns the number of elements in the
ID: 3746620 • Letter: Q
Question
Question 2 1 pts public interface List f *Returns the number of elements in the list. *@return number of elements in the list int sizeO; *Tests whether the list is empty boolean isEmpty() *Returns (but does not remove) the element at index i. Object get(int i) throws IndexOut0fBoundsException *Replaces the element at the specified index, and returns the element previously stored E set(int i, Object e) throws IndexoutOfBoundsException; Inserts the given element at the specified index of the list, shifting all *subsequent elements in the list one position further to make room void add (int i, Object e) throws IndexOutOfBoundsException; *Removes and returns the element at the given index, shifting all subsequent *elements in the list one position closer to the front Object remove(int i) throws IndexoutOfBoundsException; Consider the following sequence of operations on a List that begins empty. Give the return value for each line. If it causes an error, then write ERRORExplanation / Answer
isEmpty: False
as ew already added A so it is not empty
get(1) : B as we added it at 1 postion
size: 3
As we have 3 elements in the array A C, B so size is 3
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.