Shweta R Dhaneshwar

Ranch Hand
+ Follow
since May 27, 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 Shweta R Dhaneshwar

Please help me clear this doubt.Check out the code and its o/p.

here the correct ans is option D.

one more...

for this the correct option is B.

consider this...

here o/p is null.

I am a little confused...when do we get o/p null and when do we get NullPointerException?
Think of this in terms of array of arrays.
I am new to web programing.Can anyone tell me difference between these two in the web.xml
I took the SCJP 1.4 exam yesterday.I have got 90 %.I would like to thank all ranchers for helping me with my doubts.I did find the real exam quite easy as compared to mock exams.I did solve Dan's exams...n must say that it was a learning experience.I would like to extend special thanks to Amit Taneja for sharing his notes with me.I would also like to thank Phillips Heller for giving detailed explanation to some questions.I also liked the K&B book...with all its witty remarks...making it really interesting and believe me its fun reading that book.
Thank you all for your help and support
Shweta Dhaneshwar.
18 years ago
This question is from K&B


D and F. D is correct because the wait() method is overloaded to accept a wait duration
in milliseconds. If the thread has not been notified by the time the wait duration has elapsed,
then the thread will move back to runnable even without having been notified. F is
correct because wait()/notify()/notifyAll() must all be called from within
a synchronized, context. A thread must own the lock on the object its invoking
wait()/notify()/notifyAll() on.
A is incorrect because wait()/notify() will not prevent deadlock. B is incorrect
because a sleeping thread will return to runnable when it wakes up, but it might not necessarily
resume execution right away. To resume executing, the newly awakened thread must still be
moved from runnable to running by the scheduler. C is incorrect because synchronization prevents
two or more threads from accessing the same object. E is incorrect because notify() is not
overloaded to accept a duration. G and H are incorrect because wait() and sleep() both
declare a checked exception (InterruptedException).

What I wan't to know is that...why g is not correct choice.Isn't it true that we get a runtime exception if wait and notify are not called from the synchronized block?
Hi Sushma,
What version of java are you using?...m not getting any runtime error.

I thought that the code above will not compile since println is not reached coz while(i>52) will be false.I assumed that this code is like
do-while works fine coz even though while condition is false,the code inside do-while will be executed at least once.I am confused with the while inside do-while.It will always return false.Why don't we get compiler error saying that it is an unreachable statement?
For a shift operator,if the right hand side of the operator is negative


how is this statement evaluated?I know this topic has been discussed earlier.I'd try to search it.Can anybody provide me with the link for this solution.I would really appreciate if someone could help me with this.


I wan't to know if Java-api documents have to be studied in detail for scjp.For eg. are we expected to know something like

for the code above I had expected the o/p to be 0.Arrays are initialized irrespective of their location.This being a primitive int array,I had expected the o/p to be 0,where as ,when this piece of code is run we get a runtime exception(NullPointerException).Please explain why?
Thanks a lot for explaining in detail.
I have read in some tutorials that hashCode() is properly implemented only if it returns same int value for multiple invocations of hashCode() method on same object.See the code below.hashCode() has been invoked twice on the same object.When you compile and run this code you get two different values.This example is from Dan Chisholm's.its the 8th question.multiple choices are given as follows.please explain why e is the right choice.

a. return 31;
b. return getI1();
c. return getI2();
d. return getI1() + getI2();
e. return 31 * getI1() + getI2();
f. None of the above

finally has the final say over the exception thrown from a catch block.if it is not thrown from the finally block,the exception is simply discarded.
Hi Whitney ,

So when you add 0.5 to round(-3.2) you intuitively think you should get -3.7 but you really get -2.7 and the answer will be -2. Confusing! And it'll be on the test!

I think you are wrong here.round(-3.2) is not -2 but it is -3.

Irrespective of the number being positive or negative you have to add 0.5 to the number and then do Math.floor().