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
Naoufal18
4 days, 5 hours 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
5 months, 4 weeks ago
A is correct
upvoted 1 times
...
xplorerpj
6 months, 2 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
7 months, 3 weeks ago
A is correct answer
upvoted 2 times
...
james2033
10 months, 2 weeks 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
10 months, 3 weeks 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