wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread question . Please help . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread question . Please help ." Watch "Thread question . Please help ." New topic
Author

Thread question . Please help .

Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
1. public class SyncTest {
2. private int x;
3. private int y;
4. public synchronized void setX (int i) (x=i
5. public synchronized void setY (int i) (y=i
6. public synchronized void setXY()(set X(i); setY(i)
7. public synchronized Boolean check() (return x !=y
8. )


Under which conditions will check () return true when called from a different class?
A. Check() can never return true.
B. Check() can return true when setXY is called by multiple threads.
C. Check() can return true when multiple threads call setX and setY separately.
D. Check() can only return true if SyncTest is changed to allow x and y to be set
separately.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Does anyone know where these questions are coming from?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
Hi Barry,

Got this from some site which was giving mock exams . I don't remember the site exactly . I collected it two months ago .

Any issues in the questions .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread question . Please help .
 
Similar Threads
synchronize
Question on synchronisation
Qn on Threads
Question on threads