Skip to content
Sharp

Project Structure · interview question

Which JUnit assertion would you use to verify that a method returns a null value?

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

Correct answer

B. AssertNull

Why

The assertNull assertion in JUnit is used to verify that an object is null. It is useful for checking methods that are supposed to return null under certain conditions.

Test yourself on Project Structure

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

Start free test
All Project Structure questions →