Java Intermediate

0% completed

Previous
Next
Quiz
Question 1
What is a key feature of the List interface?
A
It allows duplicate elements.
B
It does not allow any duplicates.
C
It automatically sorts elements.
D
It does not support index-based access.
Question 2
Which of the following correctly creates an ArrayList of Strings?
Choose all correct options
ArrayList list = new ArrayList();
ArrayList list = new ArrayList();
ArrayList list = new ArrayList<>();
ArrayList list = new ArrayList();
Question 3
Which method inserts an element into an ArrayList at a specified position?
A
add(E e)
B
put(int index, E element)
C
insert(int index, E element)
D
add(int index, E element)
Question 4
Which method returns an iterator for traversing the elements of a List?
A
getIterator()
B
listIterator()
C
iterator()
D
forEach()

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next