programme:- use of inherit and use of extends..
class test
{
int x;
void prints()
{
System.out.println(x*x);
}
void sum()
{
System.out.println(x+x);
}
}
public class xyz extends test
{
int y;
xyz()
{
x=5;
}
void fromchild()
{
System.out.println("hello from child class");
}
public static void main(String args[])
{
xyz b=new xyz();
b.prints();
b.sum();
b.fromchild();
}
}
In this programme you will see that the class file is extended and how class and recall file is combined so there is no use of making another recall file.
class test
{
int x;
void prints()
{
System.out.println(x*x);
}
void sum()
{
System.out.println(x+x);
}
}
public class xyz extends test
{
int y;
xyz()
{
x=5;
}
void fromchild()
{
System.out.println("hello from child class");
}
public static void main(String args[])
{
xyz b=new xyz();
b.prints();
b.sum();
b.fromchild();
}
}
In this programme you will see that the class file is extended and how class and recall file is combined so there is no use of making another recall file.
No comments:
Post a Comment