1z0-829 Exam QuestionsBrowse all questions from this exam

1z0-829 Exam - Question 1


Given the code fragment:

and

Which is true?

Show Answer
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.

Discussion

5 comments
Sign in to comment
SampsOption: A
Feb 7, 2024

A is correct tested

james2033Option: A
Feb 11, 2024

// 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 :

minhdevOption: A
May 5, 2024

A is correct answer

xplorerpjOption: A
Jun 15, 2024

A is the correct answer. The below gets printed in random Order. t2:1: t2:2: t1:1: t1:2:

UtemanOption: A
Jul 2, 2024

A is correct