• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ch10 q2

 
zheng li
Ranch Hand
Posts: 56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

and the answer is B
but I got result of "A .".
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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").
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jason Irwin
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sachin Adat
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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......
 
Jason Irwin
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The right answer is:
A.
I spotted the lack of .
 
Mo Jay
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
MyEclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic