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

Given the code fragment:

What is the result?

    Correct Answer: C

    The code truncates both loginTime and logoutTime to the nearest minute using the truncatedTo(ChronoUnit.MINUTES) method. Since the logoutTime is only 1 second later than the loginTime, both truncated values will be the same, thus logoutTime.isAfter(loginTime) will return false. Therefore, the output will be "Can't logout".

Discussion
laura_lu93Option: C

Answer is C tested. after truncatedTo are called, LoginTime and LogoutTime are the same.

Tarik2190Option: C

Answer is C, public class Test { public static void main (String[] args) throws InterruptedException { Instant loginTime = Instant.now(); Thread.sleep(1000); Instant logoutTime = Instant.now(); loginTime = loginTime.truncatedTo(ChronoUnit.MINUTES); logoutTime = logoutTime.truncatedTo(ChronoUnit.MINUTES); if (logoutTime.isAfter(loginTime)) System.out.println("Logged out at: " + logoutTime); else System.out.println("Can't logout"); } }

WilsonKKerllOption: C

Answer is C.

asdfjhfgjuaDCVOption: C

C is the answer

MahdiHamdiiOption: C

Answer is C tested.