Question 12
Method Optional.ofNullable(T value) returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional. Based on this description, consider the code given below, and answer the question that follows.
import java.util.*;class HearingAid { String brand; String batteryType;
public HearingAid(String b, String bt) { this.brand = b; this.batteryType = bt; }}
public class Test { public static void main(String[] args) { var aidList = new ArrayList<HearingAid>(); aidList.add(new HearingAid("Phonak", "Rechargeable")); aidList.add(new HearingAid("Widex", null));
for (HearingAid obj : aidList) { Optional<String> op1 = Optional.ofNullable(obj.batteryType); op1.ifPresent(type -> System.out.println(type)); } }}Choose the correct option.