🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Java Collections (List and Set): questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. Which collection keeps elements SORTED automatically?
  3. Q3. What is the time complexity of get(i) on an ArrayList?
  4. Q4. What does this print? (code)
  5. Q5. What happens if you remove items from an ArrayList inside a for-each loop over it?
  6. Q6. What does this print? (code)
  7. Q7. What does this print? (code)
  8. Q8. Why write List<String names = new ArrayList<(); instead of ArrayList<String names = ...?
  9. Q9. What does it cost to insert an element at index 0 of an ArrayList with n elements?
  10. Q10. What does this print? (code)