Is super a reference variable in java?

494 views Asked by At

How can we write S.O.P(super.x) which should only be possible if super was a reference variable?

Is super a reference variable?

If not, does it mean that we can access non static data members stored in objects without the following syntax "reference variable"."data member"?

2

There are 2 answers

0
Sasikumar Murugesan On

We can directly access super class variable.

For Example

System.out.println(x);

Super class variable scope will based its access modifier

0
Ankur Singhal On

Few points about super

1.) super is a keyword in java

2.) A static or instance variable in a subclass may have the same name as a superclass variable. In this case, the variable hides the superclass variable and it can have same type or different types.

3.) It is possible to access hidden variable by super keyword.

4.) Note that super keyword enables you to access the superclass variable and construct a subclass by using the same variable name.