File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array Conversions
 
Similar Threads
Garbase Collection Help
How to understand this statment
Sun's Sample Q&A. Java 1.1 Question 5.
Values of Hash Map to be 2-dimensional array
initialising String variables in an array