Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. A list method E remove(int index) designed to remove and return the element a

ID: 3838066 • Letter: 1

Question

1. A list method E remove(int index) designed to remove and return the element at the given index should throw IndexOutOfBoundsException when

a. the index is 0

b.the index is negative, or is greater than, or equal to, the size of the list

the index is negative, and greater than the size of the list

the index is negative, or is greater than the size of the list

2. A Node class for a linked list that can hold elements of type Object can be declared to have fields

a. Object element; Node next;

b. Object element; next element;

c. Object element;

d. Object element; Node *next;

3. The stack push operation

a. removes and returns an item from the stack

b. returns the item at the top of the stack, but does not remove it

c. adds a single item to the stack

d. is normally implemented through a hash set

4.The stack peek operation

checks a stack to see if there are any elements in it

returns the item at the top of the stack, but does not remove it

removes and returns an item from the stack

adds a single item to the stack

5.The stack empty operation

checks to see if there is at least one item on the stack

b.destroys the stack and creates a new empty one in its place

removes all elements from the stack

None of the above

a. the index is 0

b.the index is negative, or is greater than, or equal to, the size of the list

c.

the index is negative, and greater than the size of the list

d.

the index is negative, or is greater than the size of the list

Explanation / Answer

1. A list method E remove(int index) designed to remove and return the element at the given index should throw IndexOutOfBoundsException when

Answer: d. The index is negative, or greater than the size of the list.

2. A Node class for a linked list that can hold elements of type Object can be declared to have fields

Answer: a. Object element; Node next;

3. The stack push operation is

Answer: c. adds a single item to the stack

4. The stack peek operation

Answer: b. Return the item at the top of the stack, but does not remove it.

5.The stack empty operation

Answer. d None of the above (Because the operation of stack empty is to test whether the stack is empty or not.)