class TestSuper1
{
int x =10;
TestSuper1(int p)
{
System.out.println("Super class Argumented Constructor");
}
void demo()
{
System.out.println("Super class");
}
}
class SuperTest1 extends TestSuper1
{
int x=100;
SuperTest1()
{
// super class constructor using super
super(1);
System.out.println("Sub-class Constructor");
}
public static void main(String rks[])
{
SuperTest1 t = new SuperTest1();
t.demo();
}
void demo()
{
System.out.println("Sub-class Demo");
// super class method using super
super.demo();
System.out.println("Sub-class x: "+ x);
// super class data member x using super
System.out.println("Super class x: "+ super.x);
}
}
Thanks for this article. It's just what I was searching for. I am always interested in this subject.
ReplyDeletePIC scheme
Super keyword in java
ReplyDeleteThanks for this post, it helpful for me and my all friends
Good Post! Thank you so much for sharing the nice post, it was so good to read and useful to improve
ReplyDeleteJava Training in Electronic City