This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code questions

 
assaf aharoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been in a few java Interviews recently, and the drill is to get java code questions
I give an example:


What is the result?
a. 5,5
b. 5,6
c. 1,4
d. 6,5

I would like to know if someone have a stock or a site with this kind of questions.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code button, and avoid vague thread titles.

If you are looking for jobs, you ought to know enough Java to solve that sort of question, and also what to do when ++x and y-- are used instead. Or even when the order of those two lines is swapped. You will have to go through the code with a pencil and paper, then you will know definitely what the output will be.

And, of course, the output from the code you actually quoted will be totally different. What do you think it will be.

And don't anybody else tell him!
 
assaf aharoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you sheriff,

It was just an example of an optional question :-) of course i know the answer for this one.
I'm just looking for a place i can find lots of java questions.

 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assaf aharoni wrote: . . . of course i know the answer for this one.
Really? What happens if you use that code, unchanged, inside a method?

Sorry, I don't know where there is a bank of such questions; maybe somebody else can help.
 
assaf aharoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unchanged it has error, because of missing ";" after the while(x>5)
but the real answer is 5,5
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic