/**Program For Inheritance in Java**/
import java.lang.*;
class xyz
{
int x;
public void getdata()
{
x=5;
}
public void putdata()
{
System.out.println(x);
}
}
class abc extends xyz
{
int a;
public void getdata()
{
a=7;
}
public void putdata()
{
System.out.println(a);
}
public static void main(String args[])throws Exception
{
abc a=new abc();
xyz x=new xyz();
x.getdata();
a.getdata();
x.putdata();
a.putdata();
}
}
import java.lang.*;
class xyz
{
int x;
public void getdata()
{
x=5;
}
public void putdata()
{
System.out.println(x);
}
}
class abc extends xyz
{
int a;
public void getdata()
{
a=7;
}
public void putdata()
{
System.out.println(a);
}
public static void main(String args[])throws Exception
{
abc a=new abc();
xyz x=new xyz();
x.getdata();
a.getdata();
x.putdata();
a.putdata();
}
}
No comments:
Post a Comment