Rahul Bhosale

Ranch Hand
+ Follow
since Mar 10, 2005
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rahul Bhosale

By the rules of dynamic method binding, when you call printS1S2, on object of type S, the method in type R is executed. Now, with in that method, a call to printS1() at line 1, will call its (type R's) own private version of the method and not the one defined in S (had it been overridden with a widening modifier, the overridden method would get executed) and since printS2 is overridden, the overridden method in class S is executed and hence the result. Hope that helps.
Hip hip.. yep but i missed the ACE by 4 long points. settled for 93%. (57/61).

Hey i have no regrets. This has been a wonderful experience with all of you nice people posting some intriguing questions and most importantly answering all of them patiently. I want to really thank everyone who responded to the questions i posted.
19 years ago
Is this the right link to pay for SCJP1.4. I see they describe it as a course. Wasnt sure so i thought of learning it from the ranchers.
thanks in advance.
and BTW I live in the United States of America so please advise me if i'm heading in the right direction.
outer and inner are just labels which you can use to control the flow of loops. you can use it for while and for loops.

Please give a chance for those who are going to take this exam. thanks a ton.

BTW, Moderators/Administrators : Is it ok to post questions that i've already solved but thought it would benefit others?

Choose 1 correct answer.
1. 0 0 1 0
2. 0 0 1 0 2
3. 0 0 1 0 1
4. 0 0 1 0 3

How can you access non-static members from a static method?

I guess the anwer to that question is, the member of class Class2 is being accessed in violation of protected access.
If you did this it will compile and run fine.

Raghu Shree,
Thanks for your time, but there is a logical error in your code. Anyway, the idea behind this post is to understand how 2 threads behave on shared resources and how to avoid inconsistent states of shared resources. The idea was not to fix a banking application bug.
thanks to all who responded positively particularly Joyce Lee.
Raghu Shree,
But the idea is to have 2 people access the same account. If it were 2 separate accounts, the issue of synchronization doesnt arise at all. Isnt it? Or did i miss something there. I think the correct solution posted by Joyce Lee appears to be the best unless somebody has a different way to solve it.
why is it that making the withDraw method of Account class not solving the problem either..?
I'm assuming you mean that making the withDraw method of Account class synchronized. If you make that method synchronized, you still have a state of the object which could return incorrect information to different threads.
Thanks Barry,
thanks for changing the text in the topic.

I was wondering if there was a way to change the text in the topic.. so looks like an Administrator function.. is it?
Joyce Lee,
thank you very much for your neat explanation.
thanks for posting a solution.. so happened that i too tried the same.. and worked. Thanks.

Anyway, coming to the current problem, why is it that marking the method
synchronized does not solve the problem?
thanks in advance for your responses.
[ April 11, 2005: Message edited by: Barry Gaunt ]
I was trying to solve a problem description from the Kathy Sierra & Bert Bates ' (K&B in short) book on Java Certification.
I solved the problem by changing the run method.

[ April 11, 2005: Message edited by: Barry Gaunt ]