Skip to content
Sharp

Project Structure · interview question

Which JUnit assertion would you use to check if two lists in a unit test contain the same elements in the same order?

Multiple choiceMediumchapter-10-curatedpremiumproject-structurecontinuous-integration
Choose one answer
Answer and explanation

Correct answer

A. AssertEquals()

Why

assertEquals() is used to check if two objects are equal. In the context of lists, it verifies that both lists contain the same elements in the same order.

Test yourself on Project Structure

A free test with instant, explained results. No account needed.

Start free test
All Project Structure questions →