if we have 3 classes which are inherited then al 3 have int x;
you have to print all the values of x defined in every class using overriding and this keyword.
these output function is in last class where all print statements are given.....
public class usethis {
int x=10;
}
class b extends usethis
{
int x=20;
}
class c extends b
{
int x=30;
void show()
{
//this.x=x;
System.out.println(x);
//System.out.println(x);
System.out.println(this.x);
}
public static void main(String [] args)
{
c a1=new c();
a1.show();
}
}
this keywordranjit patil January 26, 2012 at 5:26 PM
MPkwbwznmWcCuvsQsEtta September 24, 2011 at 12:49 AM
I can aledray tell that's gonna be super helpful.
please help me to solve my problemanuj sharma January 24, 2013 at 12:47 PM
if we have 3 classes which are inherited then al 3 have int x; you have to print all the values of x defined in every class using overriding and this keyword. these output function is in last class where all print statements are given..... public class usethis { int x=10; } class b extends usethis { int x=20; } class c extends b { int x=30; void show() { //this.x=x; System.out.println(x); //System.out.println(x); System.out.println(this.x); } public static void main(String [] args) { c a1=new c(); a1.show(); } }
this keywordranjit patil January 26, 2012 at 5:26 PM
thanks sir
thanks alotsameer April 7, 2012 at 2:03 AM
thanks alot for the explanation
Javalingaswamy June 27, 2012 at 4:40 PM
good example
core javamayur September 4, 2012 at 12:56 PM
explan the tostring method,
javasaurabh chuahan September 12, 2012 at 2:13 PM
i want to know about java in advance
this key wordkhemchand gautam September 28, 2012 at 10:42 AM
how to use with this key word,
java Anu June 8, 2013 at 12:04 AM
Thanks, It is written in very easy language. so really very helpful to learn concept of this keyword of java for beginners. Thanks..
Post your Comment