Help coderanch get a
new server
by contributing to the fundraiser
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

Ranch Hand
Posts: 113
• Number of slices to send:
Optional 'thank-you' note:
It is from whizlabs practice 4, and I am not good at these kinds of questions.

It seems very simple, but I found it's not easy to get the answer.
A mock question of drag and drop for simple +=,*=,%=,-=,/= operator

I am sure the real exam will have the similar questions. Please help me solve it, and how can I do it quickly?

[ April 25, 2007: Message edited by: Sam Sunamin ]
[ April 25, 2007: Message edited by: Sam Sunamin ]

author
Posts: 23956
142
• Number of slices to send:
Optional 'thank-you' note:
Sam,

Thanks,
Henry

Ranch Hand
Posts: 100
• Number of slices to send:
Optional 'thank-you' note:
x/=x

y*=y

y+=y

y-=x

How to do this quickly,and whether the exam will contain such questions i dont know.

what are the scores which you are getting in whizlabs?

Greenhorn
Posts: 14
• Number of slices to send:
Optional 'thank-you' note:
it's difficult for me too.
thank you

Ranch Hand
Posts: 447
• Number of slices to send:
Optional 'thank-you' note:
Hi

sharan
According to you statements the answer is

if you print x answer is : 1
if you print y answer is 49

i did like this

x*=y
x+=y
y/=y
y-=x

according to these statements
if you print y the answer is :-49
if you print x the answer is :50

but in the question, they are trying to print x

Thanks
anil kumar

Ranch Hand
Posts: 1710
• Number of slices to send:
Optional 'thank-you' note:
Mind Bogelling question! Is a SCJP aspirant required to face such a question?

Does anybody know any trick to solve such kind of questions.

Regards,
cmbhatt

sharan vasandani
Ranch Hand
Posts: 100
• Number of slices to send:
Optional 'thank-you' note:
change the last statement as follows in the Answer which I gave earlier.

x-=y

By mistake i did that.
[ April 25, 2007: Message edited by: sharan vasandani ]

sharan vasandani
Ranch Hand
Posts: 100
• Number of slices to send:
Optional 'thank-you' note:
please tell me what scores are you getting in whiz..?

Ranch Hand
Posts: 233
• Number of slices to send:
Optional 'thank-you' note:
There is a similar Self Test question in K&B 1.5 (p. 305).

I too would like to know any kind of trick to speed up the time needed to solve this kind of problem. I got the problem right, but it took at least 15 minutes. That�s with pencil, paper and no stress. I just tried it again watching the time and it still took me 8 minutes to solve. That�s 8 minutes to solve a problem I had solved not that long ago, maybe 5 days ago. If there�s more than one question like this on the exam I feel I am doomed.

Richard

Sam Sunamin
Ranch Hand
Posts: 113
• Number of slices to send:
Optional 'thank-you' note:
Sorry to reply to sharan late. I am really busy these days, and I don't have too much to prepare SCJP. I only get 73% in whizlab for practice 4. I think I said this in my other post. I didnot do the final test yet.

Thank you, Sharan. You are so smart to solve these kinds of questions quickly. For me, I have to give up in the realy exam. And it's definitely doomed if there are more than 2 questions in the exam.
[ April 26, 2007: Message edited by: Sam Sunamin ]

Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:
Hello,

x*=y;
y+=x;
x/=x;
x-=y;

This may give you x as -49.

--Samy

Chandra Bhatt
Ranch Hand
Posts: 1710
• Number of slices to send:
Optional 'thank-you' note:
Hi Samy,

Is there any trick to solve such kind of questions? What way you followed to answer this???

Thanks,
cmbhatt

samy kumar
Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:
Hello Chandra,

I used a bottom top approach. This might seem very vague but please don't mind. The final result required was -49 in x and so if I use a use something like x-=y where in x = 1 and y = 50 . x can be made equal to 1 by using a /= on x itself whatever may be the value of x, and before doing this get the value of y = 50 by doing x*=y; y+=x;

Thanks,
Sampath

Chandra Bhatt
Ranch Hand
Posts: 1710
• Number of slices to send:
Optional 'thank-you' note:
Good approach Samy!

Thanks,

 He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad? We need your help - Coderanch server fundraiser https://coderanch.com/t/782867/Coderanch-server-fundraiser