Exam 19: Array-Based Lists
Exam 1: Introduction to Computers and Java42 Questions
Exam 2: Java Fundamentals53 Questions
Exam 3: Decision Structures52 Questions
Exam 4: Loops and Files48 Questions
Exam 5: Methods50 Questions
Exam 6: A First Look at Classes49 Questions
Exam 7: A First Look at Gui Applications49 Questions
Exam 8: Arrays and the Arraylist Class52 Questions
Exam 9: A Second Look at Classes and Objects40 Questions
Exam 10: Text Processing and More About Wrapper Classes49 Questions
Exam 11: Inheritance49 Questions
Exam 12: Exceptions and Advanced File Io46 Questions
Exam 13: Advanced Gui Applications46 Questions
Exam 14: Applets and More39 Questions
Exam 15: Recursion34 Questions
Exam 16: Sorting, Searching, and Algorithm Analysis46 Questions
Exam 17: Generics50 Questions
Exam 18: Collections50 Questions
Exam 19: Array-Based Lists20 Questions
Exam 20: Linked Lists36 Questions
Exam 21: Stacks and Queues36 Questions
Exam 22: Binary Trees, Avl Trees, and Priority Queues45 Questions
Select questions type
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:
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:
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:
C
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)
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 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)
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)
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)