This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Conversions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array Conversions" Watch "Array Conversions" New topic
Author

Array Conversions

Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
Here is a question from DanChisholm's single topic exams. Can someone tell me why the line number 5 does not throw a NullPointerException?
We know that c is null and are trying to cast a null into an array of integers. How can that be?

Thanks,
Saket
giang nguyen
Ranch Hand

Joined: May 13, 2003
Posts: 42
Originally posted by Saket Barve:
Here is a question from DanChisholm's single topic exams. Can someone tell me why the line number 5 does not throw a NullPointerException?
We know that c is null and are trying to cast a null into an array of integers. How can that be?

Thanks,
Saket

Null pointer exeption is only thrown when you try to access a member variable or call a method on a null object.
Java allows you to cast a null object to any type, although it's still a null after casting.


SCJP 1.4, SCWCD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Array Conversions
 
Similar Threads
Values of Hash Map to be 2-dimensional array
initialising String variables in an array
Sun's Sample Q&A. Java 1.1 Question 5.
How to understand this statment
Garbase Collection Help