This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Khalids Mock exam 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 "Khalids Mock exam" Watch "Khalids Mock exam" New topic

Khalids Mock exam

Vijayalakshmi Chipada

Joined: Dec 04, 2000
Posts: 17
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(){;
public synchronized void b(){;;;
i.dec(); j.dec(); k.dec();
public void c(){;
1. i.v is guaranteed always to be 0 or 1
2. j.v is guaranteed always to be 0 or 1
3. k.v is guaranteed always to be 0 or 1
4. j.v will always be greater than or equal to k.v at any given time
5. k.v will always be greater than or equal to j.v at any given time
Can you please let me know the correct answer for this.

Ch. Vijayalakshmi

Ch. Vijayalakshmi
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
Refer to previous 2 day post the answer are i and ii

"Winners don't do different things<br /> They do things differently"
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Khalids Mock exam
It's not a secret anymore!