Question 99 of 130 from exam 1Z0-809: Java SE 8 Programmer II

Question 99 of 130 from exam 1Z0-809: Java SE 8 Programmer II

Question

Given the code fragments:

public static Optional<string> getCountry(String loc) {
Optional<string> couName = Optional.empty()7
if ("Paris".equals(loc))
couName = Optional.of ("France");
else if ("Mumbai".equals(loc))
couName = Optional.of ("India");
return couName;
Optional<string> cityl = getCountry("
Optional<string> city2 = getCountry("Las Vegas
System.out.printIn(cityl.orElse ("Not Found"));
if (city2.isPresent())

city2.ifpresent (x -> system.out.printin (x)
else

System.out.println(city2.orElse("Not Found"));

What is the result?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

D.