Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Downcasting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Downcasting" Watch "Downcasting" New topic
Author

Downcasting

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Hi,

I have given the question in the comments..Please advice.



OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Yes null value is downcasted to type Hyderabad and then automatically upcasted to AP. null value can be type casted to any type which is not a primitive...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Rahul Saple
Ranch Hand

Joined: Aug 02, 2006
Posts: 46
Yes, we are explictly downcasting the reference (Universe) to Hyderabad and the compiler does the implicit Upcasting (since it is always error free) for us. Assigning a null value is never a problem. Only using(calling a method, accessing a field) a reference pointing to no object in particular(null) leads to an exception. Infact, a non-local reference variable when declared has its default value set to null.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Downcasting
 
Similar Threads
Downcasting....
methond can be overridden not attributes? why( javaranch roundsup question)
Downcasting allowed or not ???
Color choices
In which city you stay?