• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ch10 q2

 
Ranch Hand
Posts: 56
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and the answer is B
but I got result of "A .".
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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").
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The right answer is:
A.
I spotted the lack of .
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic