class Test { public synchronized void foo() { bar(); System.out.println(\"Goodby
ID: 3660256 • Letter: C
Question
class Test { public synchronized void foo() { bar(); System.out.println("Goodbye"); } public synchronized void bar() { System.out.println("Hello"); } }When a thread invokes the foo() method on a Test object, (when no other thread is sharing this object), what would be the result?
a. The thread blocks invoking the bar() method since it is a synchronized method.
b. The output will be "Hello" followed by "Goodbye"
c. The output will be "Hello" and the thread blocks since it is a synchronized method.
d. The output will be "Goodbye" followed by "Hello"
Explanation / Answer
answer is : c. The output will be "Hello" and the thread blocks since it is a synchronized method.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.