Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Downcasting

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Rahul Saple
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic