This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes A question from Mock Exam Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "A question from Mock Exam" Watch "A question from Mock Exam" New topic
Author

A question from Mock Exam

Jisha Anand
Ranch Hand

Joined: Apr 02, 2009
Posts: 62

Dear All,

I encountered the following question while attempting a practice test in http://examprep.whizlabs.com



The answer given was: Choices B and C are the correct answers.

Is this correct?
Of course C is correct; but if B is correct the case when x == y will make z = x; where as in the given code z = y for the same case right?
I thought the question was an easy one; but now confused Please help!


SCJP, SCWCD, SCBCD
Jhakda Velu
Ranch Hand

Joined: Feb 26, 2008
Posts: 158
x=1
y=1
taking option b
the end result is still the same
whether z=x or z=y, both the answers will be the same,right?

Jhakda


If I become filthy rich, I'll sponsor research for painless dental treatment at Harvard Medical School. Thats why,I'm learning Java.I have 32 teeth, 22 are man made.
Prabz Bhatia
Greenhorn

Joined: Apr 14, 2009
Posts: 19
Hehe...
myself got confused in this one at first...

when x==y, does it matter what it returns??? Because x and y are the same!!!..


Jisha Anand
Ranch Hand

Joined: Apr 02, 2009
Posts: 62

true....how stupid i am

thanks a lot!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: A question from Mock Exam
 
Similar Threads
Mock question
x = b ? y : z ;
doubt on this question(from a Mock Test)
Garbage Collection
Command line argument question