Forums Register Login

An interview question I faced recently

+Pie Number of slices to send: Send
What gets printed for the following code snippet?




+Pie Number of slices to send: Send
Just checked in Eclipse and Java 6, got the output: 65535

Still trying to figure it out.
+Pie Number of slices to send: Send
 

Pushkar Choudhary wrote:Just checked in Eclipse and Java 6, got the output: 65535

Still trying to figure it out.




Start with, -1 in binary is represented as all 1's.
+Pie Number of slices to send: Send
A bad question. Whether you get the answer right or wrong proves nothing.

I can understand why the answer is what it is, but the question is a waste of time.
+Pie Number of slices to send: Send
I will have to admit that there were other good questions. The interviewer clearly indicated that it was an optional question to ascertain how technical I was. He was also more interested in the approach.
+Pie Number of slices to send: Send
A poor question in my opinion. Not sure how it demonstrates how "technical" a person is. If the question was about recitation of numeric casting rules it might make more sense. But to ask someone what will get "printed" is a bit looney ... and a waste of time.
+Pie Number of slices to send: Send
Refer this also Java Puzzler book have explaination about it.

According to my way of thinking the process is as follows.


first step is narrowing primitive conversions
second step + third step is widening & then narrowing primitive conversions
fourth step is widening primitive conversions
+Pie Number of slices to send: Send
 

James Clarks wrote:A poor question in my opinion. Not sure how it demonstrates how "technical" a person is.



Agreed. Obscure Java trivia questions (unless one is implementing a JVM themselves) speak far more about the interviewer than the candidate.

Cheers!

Luke
+Pie Number of slices to send: Send
 

Ninad Kulkarni wrote:Refer this also Java Puzzler book have explaination about it.

According to my way of thinking the process is as follows.


first step is narrowing primitive conversions
second step + third step is widening & then narrowing primitive conversions
fourth step is widening primitive conversions



If it was stolen from the java puzzler book, thats even worse
+Pie Number of slices to send: Send
@Deepak

If it was stolen from the java puzzler book, thats even worse



All credit goes to authors of the Java Puzzlers book for this question already in java puzzle list in their book.
I given example of binary numbers to understand multiple cast process easily in the given question by using JLS3.0.
+Pie Number of slices to send: Send
Ninad, I was not referring to you in my last post, I was referring to the person who took the interview. Just wanted to clarify that
+Pie Number of slices to send: Send
Thanks Deepak for clarification. Now I got your point.
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1943 times.
Similar Threads
Need Help! How can I......
How to make my class iterable?
Programming to interface but need access to implementation for persistence
How To Sort Multiple Columns
Two public classes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:33:47.