New course! Every coder should learn Generative AI!
Try a free lesson+ 3
In regards to Java:
Say you have class A that is the superclass of class B
The superclass can only refer to variables that have been declared within class A or within its own superclass (and their superclasses). It has no knowledge of any variables defined in class B and other descendant classes.