File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Q on Threads. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Q on Threads." Watch "Q on Threads." New topic
Author

Q on Threads.

vadiraj vd
Ranch Hand

Joined: Dec 15, 2000
Posts: 68
Hi All,
This question is from Mughal's mock exam. Could anyone give me an answer with explaination ?
Thanks,
CODE
---------
<pre>

Given the following code, which statements concerning
the objects referenced through the member variables
i, j and k are true, given that any thread may call
the methods a, b and c at any time?
class Counter {
int v = 0;
synchronized void inc() { v++; }
synchronized void dec() { v--; }
}
public class Q7ed5 {
Counter i;
Counter j;
Counter k;
public synchronized void a() {
i.inc();
System.out.println("a");
i.dec();
}
public synchronized void b() {
i.inc(); j.inc(); k.inc();
System.out.println("b");
i.dec(); j.dec(); k.dec();
}
public void c() {
k.inc();
System.out.println("c");
k.dec();
}
}

</pre>
--------
END OF CODE

------------------
Regards
---------
vadiraj

*****************
There's a lot of I in J.
*****************


Regards<BR>---------<BR>vadiraj<P><BR>*****************<BR>There's a lot of I in J.<BR>*****************
nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
http://www.javaranch.com/ubb/Forum24/HTML/007044.html


Have you tried this Mock Exam Testing Engine yet?<br /><a href="http://www.mycgiserver.com/~nan111/index.html" target="_blank" rel="nofollow">www.mycgiserver.com/~nan111/index.html</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q on Threads.