This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ch10 q2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ch10 q2" Watch "ch10 q2" New topic
Author

ch10 q2

zheng li
Ranch Hand

Joined: Jun 16, 2009
Posts: 56

and the answer is B
but I got result of "A .".
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14278
    
  21

Do you mean chapter 10, question 2 in the SCJP Study Guide by Kathy Sierra and Bert Bates? Please mention that (or at least "K&B").


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Jesper Young wrote:Do you mean chapter 10, question 2 in the SCJP Study Guide by Kathy Sierra and Bert Bates? Please mention that (or at least "K&B").


# class _ {


Surely anyone naming a class _ should be shot, stabbed and then shot again. I dont think this is from Kathy and Bert's book


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
Deepak Bala wrote:Surely anyone naming a class _ should be shot, stabbed and then shot again. I dont think this is from Kathy and Bert's book

Quite probably, but it is a legal class name and thus could appear in the exam. To be honest, lots of the code I see in the books and mocks would result in physical or verbal violence!

Anyway, to the question from the unknown book of darkest mysteries....

Class "_" is called with parameters "-", "A" and "."
Now, the thing to note is the increment section of the "for" loop. It's "++x", so x will never actually be zero in this loop, it will have the values 1 and 2.
Thus the output is "A."

And if you run the code (you did run the code, didn't you, to confirm for yourself?) that is what you get.

So either the code presented here is not what was in the book, or the options given are wrong.


SCJP6
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
Deepak Bala wrote:I dont think this is from Kathy and Bert's book

I think I saw a question like this in K&B......Self Test......


SCJP 6
How To Ask Questions On Java Ranch - How To Answer Questions On Java Ranch
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
Sachin Adat wrote:I think I saw a question like this in K&B......Self Test......

Yeah, I'm sure it's K&B being evil with extra evil, a side of evil and an extra-large evil shake.
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
Jason Irwin wrote:Yeah, I'm sure it's K&B being evil with extra evil, a side of evil and an extra-large evil shake.


Sure they are in the book, but when you are giving the exam, its just cakewalk.........
You feel its so easy.......they really toughen you for the exam.

But, anyone giving the exam beware of being careless, sometimes it makes you overconfident when you see easy questions.
You may jump straight into a pitfall....
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

The right answer is:
A.
I spotted the lack of .


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Mo Jay
Ranch Hand

Joined: Feb 16, 2009
Posts: 83
zheng li , please before you post something next time make sure to investigate carefully the output to make sure there is really a mistake in the book before posting a question like this. This question should not have been posted in the first place if you would have notice the dot(.) in the output.

Palash Kumar
Ranch Hand

Joined: Jul 21, 2009
Posts: 33

.


SCJP 6 with 80%, going for SCWCD
 
Don't get me started about those stupid light bulbs.
 
subject: ch10 q2