What method is used in AssertJ to check if an object is null?

What method is used in AssertJ to check if an object is null?

A) isNull()
B) isEmpty()
C) isNotEmpty()
D) isPresent()

Answer:

A) isNull()

Explanation:

The isNull() method in AssertJ is used to assert that an object is null. It checks whether the object reference is null.

For example:


import static org.assertj.core.api.Assertions.assertThat;

Object obj = null;

assertThat(obj).isNull();

In this example, the isNull() method asserts that the object obj is null.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top