• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How would you approach this question...

 
Milan Gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ran across this in a sample test, seemed like quite a bit of math for test question. Thought there must be some easy way to do this.
class C {
public static void main(String args[]) {
System.out.print(Long.toHexString(Long.MIN_VALUE)+",");
System.out.print(Long.toHexString(Long.MAX_VALUE));
}
}

What is the result of attempting to compile and run the program?
a. Prints: 80000000,7fffffff
b. Prints: 8000000000000000,7fffffffffffffff
c. Prints: 7fffffff,80000000
d. Prints: 7fffffffffffffff,8000000000000000
e. Prints: 00000000,ffffffff
f. Prints: 0000000000000000,ffffffffffffffff
g. Compiler Error
h. Runtime Error
i. None of the Above
 
Stefan Zoerner
Author
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... I would compile it and try it out :-)
Greetings from Hamburg,
Stefan
 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think what it boils down to is that it's one of those things you know because, no doubt, it is some manual about the nature of primitive data types such pg 97 of Just Java 2; or was seen in the
java docs.
But after just looking at all that, I still wouldn't know without actually

... I would compile it and try it out :-)

Now I know, question is: will I remember?
doco
[ April 06, 2003: Message edited by: doco mastadon ]
 
Marilyn de Queiroz
Sheriff
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Long.MIN_VALUE a positive number or a negative one?

How does java know whether a number is positive or negative?

How many bits are in a long?

How many numbers would you see in a hex string for that number of bits?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic