public class Node { private Object data; private Node leftChild; private Node rightChild; public boolean isLeaf() { return (leftChild == null && rightChild == null); } }In the above example, the isLeaf method checks whether the leftChild and rightChild of a node is null or not. If both of them are null, the node is considered as a leaf and the method returns true. Package Library: The isLeaf method is commonly used in tree data structures such as binary trees and AVL trees. It is a part of the java.util package library.