This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Please help to solve a puzzle. From whizlabs. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Please help to solve a puzzle. From whizlabs." Watch "Please help to solve a puzzle. From whizlabs." New topic
Author

Please help to solve a puzzle. From whizlabs.

Sam Sunamin
Ranch Hand

Joined: Mar 16, 2007
Posts: 113
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 ]

Yours Sam<br />SCJP5.0 97%<br />SCBCD5.0 72%
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18507
    
  40

Sam,

Interesting question. But could you please Quote Your Sources?

Thanks,
Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
sharan vasandani
Ranch Hand

Joined: Feb 22, 2007
Posts: 100
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?
Cao Bin
Greenhorn

Joined: Apr 23, 2007
Posts: 14
it's difficult for me too.
can sharan vasandani tell us how you to considered about this question.
thank you


i love you not because who you are but because who i am when i'm with you
anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
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
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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


cmbhatt
sharan vasandani
Ranch Hand

Joined: Feb 22, 2007
Posts: 100
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

Joined: Feb 22, 2007
Posts: 100
please tell me what scores are you getting in whiz..?
Richard Boren
Ranch Hand

Joined: Mar 01, 2001
Posts: 233
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

Joined: Mar 16, 2007
Posts: 113
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 ]
samy kumar
Greenhorn

Joined: Apr 16, 2007
Posts: 3
Hello,

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

This may give you x as -49.

--Samy
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Samy,

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





Thanks,
cmbhatt
samy kumar
Greenhorn

Joined: Apr 16, 2007
Posts: 3
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

Joined: Feb 28, 2007
Posts: 1707
Good approach Samy!

Thanks,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help to solve a puzzle. From whizlabs.
 
Similar Threads
return type
Mock question for ArrayList ( Drag and drop )
When to use keyword "const"? Just a reserved word.
How Inheritance Affects Serialization
mock question about interceptor of EJB3.0