aspose file tools
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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Downcasting" Watch "Downcasting" New topic


Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422

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

OCPJP 6.0-81% | Preparing for OCWCD | |
Ankit Garg

Joined: Aug 03, 2008
Posts: 9327

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.
Have you tried LearnNowOnline?
subject: Downcasting