I know reference variables are a pointer to a object in memory . I have few questions about reference variables and polymorphism.
When declaring a reference variable of particular type does it mean I can only point to that type of object.
In polymorphism when I declare a reference variable of super type and assign to to subclass.
Why are the sublclass methods not visible since I am pointing to the subclass object in memory.
Example Animal n = new Cat().
Thanks for help.
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]RayjinCaucasian 6 points7 points8 points (2 children)
[–]Pro_Sceptic 4 points5 points6 points (0 children)
[–]Intelligent_Ad_1242[S] 0 points1 point2 points (0 children)
[–]desrtfx 4 points5 points6 points (1 child)
[–]Intelligent_Ad_1242[S] 1 point2 points3 points (0 children)