Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Code questions  RSS feed

 
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.
 
Marshal
Posts: 60072
188
  • 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
Marshal
Posts: 60072
188
  • 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
Marshal
Posts: 60072
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!