class A
{
int i,j;
void show()
{
System.out.println("i and j: "+i+" "+j);
}
}
class B extends A
{
int k;
void show()
{
System.out.println("k: "+k);
}
void sum()
{
System.out.println("i+j+k: "+(i+j+k));
}
}
public class Seventeen {
public static void main(String args[])
{
A SupOb=new A();
B SubOb=new B();
SupOb.i=10;
SupOb.j=15;
SupOb.show();
SubOb.k=20;
SubOb.show();
SubOb.i=5;
SubOb.j=18;
SubOb.k=7;
SubOb.sum();
}
}
{
int i,j;
void show()
{
System.out.println("i and j: "+i+" "+j);
}
}
class B extends A
{
int k;
void show()
{
System.out.println("k: "+k);
}
void sum()
{
System.out.println("i+j+k: "+(i+j+k));
}
}
public class Seventeen {
public static void main(String args[])
{
A SupOb=new A();
B SubOb=new B();
SupOb.i=10;
SupOb.j=15;
SupOb.show();
SubOb.k=20;
SubOb.show();
SubOb.i=5;
SubOb.j=18;
SubOb.k=7;
SubOb.sum();
}
}
No comments:
Post a Comment