Super keyword

We shall use the super keyword for accessing the value of the shadowed variable.

 

class E
{ String x=”JAVA”;}
class F extends E
{
String x =”CORBA”;
void display()
{
Sytem.out.println(x);
Sytem.out.println(super.x);
}
}
class EFdemo
{
public static void main(String[] args)
{
F f= new F();
f.display(); } }

output is
CORBA
JAVA

 

 

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.