What is the result?

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?

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?

A.
Travel time is 4 hours

B.
Travel time is 6 hours

C.
Travel time is 8 hours

D.
An exception is thrown at line n1.



Leave a Reply 8

Your email address will not be published. Required fields are marked *


Berti John

Berti John

A. is correct

Pinco

Pinco

Correct answer A, tested

dazladhoyya

dazladhoyya

How did people get answer A ?

dazladhoyya

dazladhoyya

If anyone has working code will you please post in on the reply/comment section

dazladhoyya

dazladhoyya

Hello, could someone post the working code