ExamQuestions.com

Register
Login
Java SE 8 Programmer II Exam Questions

Oracle

Java SE 8 Programmer II

30 / 130

Question 30:

Given the code fragments: class Employee{ Optional<Address> address; Employee (Optional<Address> address){ this.address = address; } publicOptional<Address> getAddress(){return address;} } class Address{ String city = "New York"; public String getCity{return city:} public String toString() { return city; } } and Address address = null; Optional<Address> addrs1 = Optional.ofNullable (address); Employee e1 = new Employee (addrs1); String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not available"; What is the result? 

Answer options:

A. New York
B. City Not available
C. null
D. A NoSuchElementException is thrown at run time.