exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 166 discussion

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

Given:
and the code fragment:

The threads t1 and t2 execute asynchronously and possibly prints ABCA or AACB.
You have been asked to modify the code to make the threads execute synchronously and prints ABC.
Which modification meets the requirement?

  • A. start the threads t1 and t2 within a synchronized block.
  • B. Replace line n1 with: private synchronized int count = 0;
  • C. Replace line n2 with: public synchronized void run () {
  • D. Replace line n2 with: volatile int count = 0;
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
JME_CHG
Highly Voted 3 years, 4 months ago
C is correct, A does nothing...
upvoted 7 times
...
steefaand
Most Recent 5 months, 4 weeks ago
Selected Answer: C
C is answer.
upvoted 1 times
...
iSnover
5 months, 4 weeks ago
Selected Answer: C
The answer is letter C, answer A does not print anything on the screen and the run() method needs to be syncronized.
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
public void run() { while(count < src.length){ System.out.println(src[count++]); } }
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
I think C is answer.
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