The ifPresent() and ifPresentOrElse() methods of the Optional class in Java 8 provide a functional style way to perform different actions depending on whether the Optional object is empty or contains a value.