Loading

Q1. What is the List interface in Java?

The List interface in Java is part of the Collections Framework. It represents an ordered collection that allows duplicate elements and maintains insertion order.






Q2. What is the difference between List and Queue in Java?
  • List Used when you need ordered collection with random access.
  • Queue Used when elements should be processed in FIFO or LIFO order (depending on implementation).





Q3. How does List handle ordering of elements?

A List maintains insertion order, meaning elements are retrieved in the same sequence they were added.






Q4. What is the difference between List and Array in Java?
  • Array Fixed size, stores primitive types or objects, no built-in methods for resizing.
  • List Dynamic size, part of Collections Framework, provides rich methods like add(), remove(), contains().





Q5. What happens if you access an index outside the List range?

Java throws an IndexOutOfBoundsException at runtime when accessing an invalid index.