Exam 19: Array-Based Lists

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

A new element is added to an ArrayList object at index k.Assuming the list has size s and does not have to be resized,

Free
(Multiple Choice)
4.9/5
(34)
Correct Answer:
Verified

B

A constructor for an array-based list takes an integer parameter,to be used as the capacity of the internal array of the list.Which exception should the constructor throw if its parameter is zero or negative?

Free
(Multiple Choice)
4.8/5
(36)
Correct Answer:
Verified

A

The E get(int index)method of the List interface should throw an exception if

Free
(Multiple Choice)
4.8/5
(37)
Correct Answer:
Verified

C

The size of an array-based list such as ArrayList

(Multiple Choice)
4.8/5
(37)

If a new element is added to an ArrayList whose internal array if already full,

(Multiple Choice)
4.9/5
(31)

What is the difference between the Iterator and Iterable interfaces? How would you use these two interfaces if you had to write a collection class?

(Essay)
5.0/5
(41)

The position of an item within a list is called its

(Multiple Choice)
4.8/5
(42)

The capacity of an array-based list such as ArrayList

(Multiple Choice)
4.9/5
(41)

Assume an array-based list implemented by a class that uses the fields String [ ] list; int nElements; to represent the array of elements,and the number of elements currently stored.Show the code for a method int size( )that returns the current size of the list.

(Essay)
4.8/5
(40)

Assume an array-based list implemented by a class that uses the fields String [ ] list; int nElements; to represent the array of elements,and the number of elements currently stored.Show the code for a method void clear()that removes all elements from the list.

(Essay)
4.8/5
(38)

Assume an array-based list implemented by a class that uses the fields String [ ] list; Int nElements; To represent the array of elements,and the number of elements currently stored.Assuming there is space In the internal array,the code for adding a new item str to the end of the list is

(Multiple Choice)
4.9/5
(36)

Assume an array-based list implemented by a class that uses the fields String [ ] list; int nElements; to represent the array of elements,and the number of elements currently stored.Show the code for a constructor that creates a list with a default capacity of 100.

(Essay)
4.9/5
(40)

Why does the Java Collections Framework define a List as an interface rather than a class?

(Multiple Choice)
4.9/5
(43)

Assume an array-based list implemented by a class that uses the fields String [ ] list; int nElements; to represent the array of elements,and the number of elements currently stored.Show the code for a method boolean empty()that determines whether the list is empty.

(Essay)
4.8/5
(41)

The int indexOf(Object o)method of the List interface

(Multiple Choice)
4.9/5
(38)

The boolean contains(E element)method searches a ArrayList for a given element.A correct and efficient implementation of this method

(Multiple Choice)
4.8/5
(36)

Assume an array-based list implemented by a class that uses the fields String [ ] list; int nElements; to represent the array of elements,and the number of elements currently stored.Show the code for a method String set(int index,String str)that sets the element at the given index to str and returns the element previously stored there.

(Essay)
4.9/5
(41)

An ArrayList is so called because

(Multiple Choice)
4.9/5
(41)

Assume an array-based list implemented by a class that uses the fields String [ ] list; int nElements; to represent the array of elements,and the number of elements currently stored.Show the code for a method String remove(int index)that removes and returns the element at the given index.The method should throw an appropriately named exception if it cannot return the requested element.

(Essay)
4.8/5
(38)

The difference between an array and an ArrayList is

(Multiple Choice)
4.8/5
(40)
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)