This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes null = 0? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "null = 0?" Watch "null = 0?" New topic

null = 0?

Travis Benning
Ranch Hand

Joined: Jan 24, 2002
Posts: 74
I've hit a question that is on two mocks:
On Jxam:
answer = 0
On another mock (forgot name):
answer = error

Now I initially thought it was 0, but I took the second one first and got error, so I remembered this, and then on Jxam I get it wrong again.
Can someone please clarify this please?
All help appreciated,
Travis B.

Sun Certified Programmer for Java 2 Platform
Rowan Chattaway
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
Travis, this is what happens when I tried to run it:
Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Parser.main(
so, I guess the answer is error!?

The early bird may get the worm, but the second mouse gets the cheese.........<br /> <br />Sun Certified Programmer for Java 2 Platform<br />Sun Certified Web-Component Developer for J2EE Platform
Travis Benning
Ranch Hand

Joined: Jan 24, 2002
Posts: 74
Thanks Rowan.
and a big DUH!! for me. lol
After all my studying overnight and everything.... the simplest thing would have been to test it myself, but I missed it. lol.
This must mean I need sleep.
Thanks for your help Rowan.
Travis B.
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Travis here is one way to think about it (in java).
A null is an undefined value, while zero in a defined value. So trying to display an 'null' value could have one of two results:
a) it outputs the literal 'null'
b) it results in an runtime error
there is no easy way to guess if the correct answer is a) or b) without actually trying it out with java and seeing how the creators of the language wanted it to (mis)behave
[ March 06, 2002: Message edited by: Rajinder Yadav ]

<a href="" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Consider Paul's rocket mass heater.
subject: null = 0?
It's not a secret anymore!