Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Downcasting  RSS feed

 
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: 9608
36
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!