Oracle
1Z0-809 · Question #201
1Z0-809 Question #201: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #201. The question stem and answer options stay visible for context.
Question
Given the code fragments: public static Optional<String> getCountry(String loc) { Optional<String> couName = Optional.empty(); if ("Paris".equals(loc)) couName = Optional.of("France"); else if ("Mumbai".equals(loc)) couName = Optional.of("India"); return couName; } and Optional<String> city1 = getCountry("Paris"); Optional<String> city2 = getCountry("Las Vegas"); System.out.println(city1.orElse("Not Found")); if (city2.isPresent()) System.out.println(x -> System.out.println(x)); else System.out.println(city2.orElse("Not Found")); What is the result?
Options
- AFrance Optional[NotFound]
- BOptional[France] Optional[NotFound]
- COptional[France] Not Found
- DFrance Not Found
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.