Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 82

Given the code fragment:

ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of("UTC-7"));

ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of("UTC-5")); long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1

System.out.println("Travel time is" + hrs + "hours");

What is the result?

    Correct Answer: C

    The code fragment creates two ZonedDateTime instances representing departure and arrival times in different time zones. The departure is at 3:00 AM in UTC-7, and the arrival is at 9:00 AM in UTC-5. Both times are on the same date. The time difference between UTC-7 and UTC-5 is 2 hours (UTC-5 is 2 hours ahead). Thus, if we adjust the departure time to the UTC-5 zone, we get 5:00 AM as the departure time when converted to UTC-5. Hence, the time between 5:00 AM and 9:00 AM is 4 hours plus the 2 hours difference between the zones, making the total travel time 6 hours. Therefore, the correct answer is 6 hours.

Discussion
adnano1234Option: A

The answer is A

SamriddjiOption: A

A, tested

asdfjhfgjuaDCVOption: A

A is the correct answer

steefaandOption: A

Answer is A