• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Please help to solve a puzzle. From whizlabs.

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam,

Interesting question. But could you please Quote Your Sources?

Thanks,
Henry
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's difficult for me too.
can sharan vasandani tell us how you to considered about this question.
thank you
 
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please tell me what scores are you getting in whiz..?
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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

This may give you x as -49.

--Samy
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Chandra,

Sorry for the late reply.
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good approach Samy!

Thanks,
 
I knew that guy would be trouble! Thanks tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic