In Java a reference variable of superclass is assigned to sub class . ls superclass knows the variables and methods of subclass | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

In Java a reference variable of superclass is assigned to sub class . ls superclass knows the variables and methods of subclass

Java

11th Apr 2019, 2:06 PM
Pravallika
2 Answers
+ 1
It depends on type of object not the type of reference
13th Apr 2019, 3:35 PM
Pravallika
0
I think inheritance works only downstream. Anyway the child class methods and variables will be visible for the parent class if they are public.
11th Apr 2019, 5:37 PM
Nonea
Nonea - avatar