Flashcards

Quick study sessions to strengthen memory and retain key concepts.

Flashcard Study

Java: List Interface and ArrayList

Front

Explain the List contract regarding element equality and order?

Lists must maintain insertion order and rely on equals() for equality. The List interface guarantees that elements maintain…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

What happens if you modify a List while iterating over it using a for-each loop?

Causes ConcurrentModificationException. Frame the concept in practical terms so you can explain it during interview discussion. Modifying a…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

How would you explain a common mistake beginners make when using arrays instead of ArrayLists in an interview?

Arrays have fixed size; ArrayLists do not. Beginners often overlook that arrays have a fixed size, meaning they…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

Explain the tradeoff of using an ArrayList for frequent insertions at the beginning?

Frequent beginning insertions degrade performance. Inserting at the beginning of an ArrayList requires shifting all elements, leading to…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

How does indexed access in ArrayList differ from insertion?

Indexed access is fast; insertion can be slow. ArrayLists provide fast indexed access (O(1)) since elements are stored…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

Which behavior of an ArrayList when it exceeds its initial capacity is the default in Java?

It automatically increases its capacity. Frame the concept in practical terms so you can explain it during interview…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

Why is an ArrayList suitable for maintaining an ordered collection with duplicates?

ArrayList maintains order and allows duplicates. An ArrayList preserves the order of elements as they were added and…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

Reading code: Spotting off-by-one errors in List loops?

Off-by-one errors often occur in loop bounds. When iterating over a List, off-by-one errors can occur if you…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

How does ArrayList maintain element order?

ArrayList maintains insertion order. Frame the concept in practical terms so you can explain it during interview discussion.…

View Card →
Flashcard Study

Java: List Interface and ArrayList

Front

Performance implications of ArrayList's dynamic resizing?

Resizing involves copying elements, leading to O(n) complexity. ArrayList grows dynamically when it exceeds its capacity by creating…

View Card →