aspose file tools*
The moose likes Jobs Discussion and the fly likes An interview question I faced recently Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Careers » Jobs Discussion
Bookmark "An interview question I faced recently" Watch "An interview question I faced recently" New topic
Author

An interview question I faced recently

arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3223
What gets printed for the following code snippet?





Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Pushkar Choudhary
Rancher

Joined: May 21, 2006
Posts: 425

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

Still trying to figure it out.
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3223
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.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

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.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3223
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.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
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.
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 797

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


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Luke Kolin
Ranch Hand

Joined: Sep 04, 2002
Posts: 336
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
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

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
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 797

@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.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

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
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 797

Thanks Deepak for clarification. Now I got your point.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An interview question I faced recently