File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes How would you approach this question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How would you approach this question..." Watch "How would you approach this question..." New topic

How would you approach this question...

Milan Gupta

Joined: Aug 03, 2002
Posts: 7
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[]) {

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

Joined: Nov 29, 2001
Posts: 121
... I would compile it and try it out :-)
Greetings from Hamburg,

Stefan Zoerner
Author of German LDAP-Book
Committer at Apache Directory Project
Donald R. Cossitt
Ranch Hand

Joined: Jan 31, 2003
Posts: 401

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?
[ April 06, 2003: Message edited by: doco mastadon ]

Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
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?

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: How would you approach this question...
It's not a secret anymore!