aspose file tools*
The moose likes Java in General and the fly likes Code questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Code questions" Watch "Code questions" New topic
Author

Code questions

assaf aharoni
Greenhorn

Joined: Aug 08, 2010
Posts: 9
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

Joined: Oct 13, 2005
Posts: 39877
    
  28
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

Joined: Aug 08, 2010
Posts: 9
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

Joined: Oct 13, 2005
Posts: 39877
    
  28
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

Joined: Aug 08, 2010
Posts: 9
unchanged it has error, because of missing ";" after the while(x>5)
but the real answer is 5,5
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39877
    
  28
Agree.
 
 
subject: Code questions