File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Code execution flow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Code execution flow" Watch "Code execution flow" New topic

Code execution flow

Kedar Dravid
Ranch Hand

Joined: May 28, 2004
Posts: 333
Consider the code below:

O/p: index=2
How is it that line 2 doesn't result in a NullPointerException, since getArray() returns null? Or is it that the NullPointerException is caught in the catch block (which does nothing), and then the value 2 from [index=2] printed?
Kindly correct me if I am wrong.

[ March 08, 2005: Message edited by: Mark Spritzler ]
[ March 08, 2005: Message edited by: Mark Spritzler ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Keder, I edited your post to add the CODE tags, and made the code a bit more readable for everyone.

Good Luck


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
How about printing something in the catch block? Then you will be able to test your hypothesis.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: Code execution flow
It's not a secret anymore!