Program to illustrate the concept of hiding of a variable

class W
{ int I =11;}
class X extends W
{ int I = 22;}
class WXdemo
{
public static void main(String[] args)
{
X x1 = new X();
System.out.println(“Value of I in class X = “ + x1.I);
}}
output is 22

 

Share

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.