The output can never contain the value 10. The output can never contain the value 30. The output can never contain the value 297. The output can never contain the value 820. The output can never contain the value 1010.
i am not finding the fact behind the questions that is why i am asking.if it is not answering machine then stop this forum and do rest at home because everyone here is to get answer to his question.if you can not give answer then just stay quite and let others consider. thank you.
[BPS: Removed code tags] [ April 29, 2008: Message edited by: Ben Souther ]
i am not finding the fact behind the questions that is why i am asking.if it is not answering machine then stop this forum and do rest at home because everyone here is to get answer to his question.if you can not give answer then just stay quite and let others consider. thank you
manny singh, Our first and most important rule here is to be nice.
Jesper is a staff member at Javaranch and is a moderator of this forum. He is donating his time to help keep this forum running well.
Part of this task involves letting people know when they not asking well formed questions. There is a difference between asking for help and asking someone to do the work for you. Pasting a mock question into the forum and asking someone to answer it and explain why their answer is correct falls in the later category and is not encouraged here.
-Ben
[ April 29, 2008: Message edited by: Ben Souther ] [ April 29, 2008: Message edited by: Ben Souther ]
In addition to the link posted above, please also see UseRealWords. Wrapping your posts in code tags to overcome Javaranch's checks for non-words causes your text not to wrap and be displayed in a mono spaced font. These things make your posts much harder to read and thus, less likely to get a meaningful answer.
-Ben
manny singh
Greenhorn
Joined: Jan 18, 2008
Posts: 28
posted
0
sorry
BYE FORUM
Vishal Matere
Ranch Hand
Joined: Jan 22, 2008
Posts: 81
posted
0
Originally posted by manny singh:
Which is true?
The output can never contain the value 10. The output can never contain the value 30. The output can never contain the value 297. The output can never contain the value 820. The output can never contain the value 1010.
Manny, if you're still here, I'd like to clarify something. The ranchers and moderators here have a LOT of experience when it comes to preparing for, and passing the SCJP. Our combined experience tells us that the way to pass the exam is to write a lot of code, and experiment with the mock questions that you're studying. It won't work to try to memorize stuff, it works when you actually LEARN the concepts that drive the code.
So, we're not being unfriendly when we ask you to do more work before asking your questions, we're asking you to do what works! We want you to pass this exam!
hth,
Bert
Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
manny singh
Greenhorn
Joined: Jan 18, 2008
Posts: 28
posted
0
i am extremely sorry for the question i asked and my behavior. i was asking this because one can't have permission to go to compile in the test so how do come to result.
You're correct in that you can't compile during the test but when studying for the test the best thing you can do is write, compile, and run lots of code.
Try to figure out what the answers are for the last 3 questions that you posted here. Then, compile and run them to see if you were correct. If not, play with the examples. Add println statements to different parts of them to see what the values of the variables are at various stages in the execution. You'll learn a lot more about Java by doing this than by trying to remember answers given by other people here.
Then, if you're still having a hard time with a concept, you'll most likely have a much more specific question to ask. Maybe even a code example of your own that does a better job communicating your issue than the mock tests from a book or web site.
Glad you stuck around. -Ben
Ivan Ivanic
Ranch Hand
Joined: Oct 31, 2007
Posts: 100
posted
0
hey manny i totally understand you. in some other java forums people are really rude. but in my experience here i really saw that here every critic is justified. if you follow what this good men say, it will be much easier for you to get help. and it will be much easier for rest of us to help you. i wish you to have a clear mind and when you come to your limits, you are always welcome to get some clarifications. it is kinda tough to get used to this kind criticism, if you have bad experience from other forums, but in the end it will help you be a better java programmer. and of course to pass exam. best luck.
Irina Goble
Ranch Hand
Joined: May 09, 2004
Posts: 75
posted
0
Originally posted by Vishal Matere: Answer 3 is correct. 297 is not valid value.
Could you please explain this? Compiling and running does not guaranteed that you get all the correct answers here. While some threads will increment i only 10 times, others might do that 11 times. So why is 297 not valid? Thank you.
[ April 29, 2008: Message edited by: Irina Goble ]
I missed the whole point. Thread.yield() does not release the lock! [ April 29, 2008: Message edited by: Irina Goble ]
Vishal Matere
Ranch Hand
Joined: Jan 22, 2008
Posts: 81
posted
0
Originally posted by Irina Goble:
I missed the whole point. Thread.yield() does not release the lock!
[ April 29, 2008: Message edited by: Irina Goble ]
There you got it. However rather than simply running code, a good inspection of code itself will tell you that 297 is never possible.
vasu chowdary
Ranch Hand
Joined: Mar 15, 2008
Posts: 84
posted
0
public synchronized void run() { }.....compile time error run method is not override. you will better to write public void run() { synchronized(this) { } }
Originally posted by vaasu balu: public synchronized void run() { }.....compile time error run method is not override. you will better to write public void run() { synchronized(this) { } }
Dear Vaasu,
The following code:
public synchronized void run() { }
will compile successfully and it is equivalent to the following code:
public void run() { synchronized(this) { } }
Please check it to make sure. [ May 01, 2008: Message edited by: Hussam Odeh ]