exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 132 discussion

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

Given the code fragment:

What is the result ?

  • A. [X] [X, X] [X, X, X] [X, X, X, X]
  • B. [X, X]
  • C. [X] [X, X] [X, X, X]
  • D. [X, X] [X, X, X, X]
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
jduarte
Highly Voted 3 years, 6 months ago
Answer D, tested
upvoted 8 times
...
steefaand
Most Recent 5 months, 4 weeks ago
Selected Answer: D
Answer is D. CyclicBarrier is reached 2 times and first time list contains 2 Xs and second time it contains 4 Xs.
upvoted 1 times
...
MatthewTannous
2 years ago
Selected Answer: D
Answer D - tested
upvoted 1 times
...
Svetleto13
3 years, 2 months ago
D,tested
upvoted 3 times
Svetleto13
3 years, 2 months ago
If we write that: final CyclicBarrier barrier = new CyclicBarrier(1, new Runnable() answer is A.
upvoted 2 times
...
...
Abdullah_Rahahleah
3 years, 7 months ago
Answer is D [X, X] [X, X, X, X]
upvoted 4 times
...
pul26
3 years, 7 months ago
Answer is A, tested public static void main(String[] args) { final List<String> list = new CopyOnWriteArrayList<>(); final AtomicInteger ai = new AtomicInteger(0); final CyclicBarrier barrier = new CyclicBarrier(2, new Runnable() { @Override public void run() { System.out.println(list); } }); Runnable r = new Runnable() { @Override public void run() { try { Thread.sleep(1000 * ai.incrementAndGet()); list.add("X"); barrier.await(); }catch (Exception e){ } } }; new Thread(r).start(); new Thread(r).start(); new Thread(r).start(); new Thread(r).start(); } output : [X, X] [X, X, X, X] //CyclicBarrier works for all every 2 threads reached to the barrier
upvoted 2 times
Tarik2190
3 years, 2 months ago
Based on your output, answer should be D.
upvoted 3 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