Rahul Ghodeswar

+ Follow
since Mar 06, 2006
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 Ghodeswar

Hi Rushikesh,

D) is also wrong. The finalize method is tipically used to free up memory resources...........

I dont think this is correct. Finalize method is typically used to free resources other than memory, since memory will be freed by the Garbage colletctor.

Hence both A & D are correct options.

In the first code sample the inherited copy of method x() is called from object B, which very legal as x() is an public method. So we get o/p = 4.

But in next code sample, class B overrides method x() and try to access the private member variable 'x' of parent class. This is not legal as private mebers are not accessible to child class, hence we get a compiler error in this case.
Hi Nikki,

Its just superb score...no more words to descride.
Please guide us me as I'm thinking of giving the SCJP exam in next 10 days.
I've completed K&B book, but still not feeling confident enough for the exam. Currently I'm giving mock test online & that of Khalid Moughl.

Please tell some tips for such a great score..

Hi Vidya,

what is this Dan chilosm's section topic exams? where will we get it?

The Dan Chisholm provides you with a very good stuff for the SCJP preparations. His questions on each topic (section) of exam are really very good and good standards. So if you want to test your preparations you can try his tests which are given section wise i.e. topicwise.

You can get them at http://www.danchisholm.net/july21/mybook/index.html
[ March 08, 2006: Message edited by: Rahul Ghodeswar ]
18 years ago
Hi Edisandro,

The wait() and notify() methods provides mean to enable the inter-thread communication. Two threads which are running simultaneously may require that one thread should be blocked till another one completes its processing. e.g. If thread Menu gives the items to be ordered and thread Meal prepares meal, then Meal thread should be blocked till Menu thread completes its execution. So Thread Meal will call menu.wait() to wait for menu to run through its code. This means that Thread Meal is not going to run till Thread Menu is over with its run method and it notifies all the waiting threads on this object, ehich is Meal in our case. This it does by calling notify() method. This call to notify() method means that all the threads waiting for this thread ( rather Object) can have its lock now and can proceed with there execution.

So when an object A calls b.wait(2000), it means that it has to wait for thread 'b' to complete its execution atleast for 2 seconds otherwise it will go to Runnable state, but not Running state untill it acquires the lock for the object 'b'. And B will tell ( i.e. notify) all the waiting thread by calling notify method and this can be termed as "B is notified".

I hope I was able to make the scene somewhat clear. But if I'm not then please let me know.
[ March 07, 2006: Message edited by: Rahul Ghodeswar ]
Hi Arthur,

First of all thanks for a really good question on Inner classes. Dan really lived up to his fame of quality questions. The the basic confusion in this question is the object creation part for Class A. If you keep track of the object created and there value of private instance variable 'name', you will get the key to the problem. The object created by statement
A a1 = new A()
have name = "A0". This object is used to call method m1, which in turn creates a new object of class A which will have name = "A1" , since counter has incremented to 1 now. Now this object (with name="A1" ) is used to create object of inner class B -
new A().new B()
So we get "A1B0" on the console for the constructyor of this object.
Now the same old object created earlier i.e. 'a1' (with name = "A0") is used to call methods m2 & m3. In both methods this 'a1' is used to create the new inner class objects so we get "A0B1" for method m2 and "A0B2" for method m3. See method m3(). It is not having any reference to the current object of outer class A, but by default it uses 'this' since we always require a outer class object reference to create an inner class object. So both m2 & m3 are using the the same object 'a1' hence we get "A0" back.

Hope I was able to clear your confusion. If not reply frankly. I'll try to explain in more elaborate way.
[ March 06, 2006: Message edited by: Rahul Ghodeswar ]