#Upcasting, Downcasting and Declaring Objects

4 messages · Page 1 of 1 (latest)

desert loom
#

Can somebody explain how Upcasting and Downcasting work? Say I have a Parent class and a Child that extends the Parent, Like why can't I access the attributes of the subclass that's Upcasted to the Parent but only the attributes of the Parent. Also everything I need to know about declaring variables especially objects. Sorry if my question didn't make sense, I just started learning Java like a week ago.

woven meteorBOT
#

This post has been reserved for your question.

Hey @desert loom! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

slim summit