exam questions

Exam 1z0-829 All Questions

View all questions & answers for the 1z0-829 exam

Exam 1z0-829 topic 1 question 1 discussion

Actual exam question from Oracle's 1z0-829
Question #: 1
Topic #: 1
[All 1z0-829 Questions]

Given the code fragment:
and

Which is true?

  • A. The program prints t1 : 1 : t2 : 1: t1 : 2 : t2 : 2 : in random order.
  • B. The program prints t1 : 1 : t2 : 1: t1 : 2 : t2 : 2 :
  • C. The program prints t1 : 1 : t2 : 1: t1 : 1 : t2 : 1 : indefinitely.
  • D. The program prints an exception.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
1 week, 1 day ago
Selected Answer: A
Only one thread t1 has access to Test.x. Only one thread t2 has access to Test.xObj. Monitor (implicit synchronization) of Instance class Test is not used. There is no thread interference at all here. Even if we remove keyword volatile and exchange optimistic locking AtomicInteger variable regular Integer the thread execution order is generally unpredictable because of not absolute contract with underlying OS in order to perform threads scheduling.
upvoted 1 times
...
Naoufal18
3 months, 1 week ago
Selected Answer: A
n the given code, two threads (t1 and t2) are running concurrently and printing the values of x and xObj, respectively. The execution order of the threads can vary due to their concurrent nature. Here's the breakdown: Thread 1 (t1) is operating on the volatile int x variable. It increments x from 1 to 2 as part of the while (t.x < 3) loop. Thread 2 (t2) is operating on the AtomicInteger xObj. It increments xObj from 1 to 2 and then to 3 as part of the while (t.xObj.get() < 3) loop.
upvoted 1 times
...
Uteman
9 months ago
A is correct
upvoted 1 times
...
xplorerpj
9 months, 3 weeks ago
A is the correct answer. The below gets printed in random Order. t2:1: t2:2: t1:1: t1:2:
upvoted 1 times
...
minhdev
11 months ago
A is correct answer
upvoted 2 times
...
james2033
1 year, 1 month ago
Selected Answer: A
// Result: // t2 : 1 : t2 : 2 : t1 : 1 : t1 : 2 : // t1 : 1 : t2 : 1 : t2 : 2 : t1 : 2 : // t1 : 1 : t2 : 1 : t1 : 2 : t2 : 2 : // t1 : 1 : t2 : 1 : t1 : 2 : t2 : 2 :
upvoted 2 times
...
Samps
1 year, 1 month ago
A is correct tested
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago