Java SE 17 Developer

Here you have the best Oracle 1z0-829 practice exam questions

  • You have 50 total questions to study from
  • Each page has 5 questions, making a total of 10 pages
  • You can navigate through the pages using the buttons at the bottom
  • This questions were last updated on November 13, 2024
Question 1 of 50

Given the code fragment:

and

Which is true?

    Correct Answer: A

    The program starts two threads, t1 and t2. The first thread (t1) increments and prints the volatile integer x variable until it is less than 3, while the second thread (t2) increments and prints the AtomicInteger xObj until it is less than 3. Since both increment and print their respective values independently, their outputs can interleave in any order, thus, the program prints t1: 1: t2 : 1: t1 : 2 : t2 : 2: in random order.

Question 2 of 50

Which statement is true?

    Correct Answer: D

    A thread in waiting state must handle InterruptedException. When a thread is in a waiting state, it can be interrupted, and it needs to handle InterruptedException to manage this situation appropriately and move back to a runnable state. This ensures that the thread can be managed and controlled correctly.

Question 3 of 50

Daylight Saving Time (DST) is the practice of advancing clocks at the start of spring by one hour and adjusting them backward by one hour in autumn.

Considering that in 2021, DST in Chicago (Illinois) ended on November 7th at 2 AM, and given the fragment:

What is the output?

    Correct Answer: C

    When Daylight Saving Time ends, the clocks are turned back one hour. On November 7, 2021, in Chicago, the time from 1:00 AM to 2:00 AM occurs twice: once during Daylight Saving Time (UTC-5) and once during Standard Time (UTC-6). This means that 1:30 AM DST and 1:30 AM Standard Time are the same local times but with different offsets. Therefore, the hour remains the same (`true`), but the UTC offset changes (`false`).

Question 4 of 50

Given the code fragment:

What is the result?

    Correct Answer: A

    The method truncatedTo(ChronoUnit.MINUTES) truncates the Instant object to the nearest minute. Given the loginTime of 2021-01-12T21:58:18.817Z and the logoutTime of 2021-01-12T21:58:19.880Z, both will be truncated to 2021-01-12T21:58:00Z. After truncation, loginTime and logoutTime are equal, so logoutTime.isAfter(loginTime) will return false, and the else statement will execute, printing 'Can't logout'.

Question 5 of 50

Given the code fragment:

What is the result?

    Correct Answer: B

    The code fragment defines and prints a Duration and a Period. Initially, a Duration of 5000 milliseconds is created, which equals to 5 seconds and will be printed as PT5S. Then the Duration is updated to 60 seconds, which equals to 1 minute and will be printed as PT1M. Finally, a Period of 6 days is printed as P6D. Therefore, the output of the program will be PT5SPT1MP6D.