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

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.

Discussion
james2033Option: 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 :

SampsOption: A

A is correct tested

UtemanOption: A

A is correct

xplorerpjOption: A

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

minhdevOption: A

A is correct answer