Program to Implement Overriding of Methods
class bca
{
int d;
void get(int x)
{
d = x;
}
void display()
{
System.out.println("Bca = " + d);
}
}
class mca extends bca
{
int y;
mca(int m, int y)
{
get(m);
this.y = y;
}
void display()
{
System.out.println("Bca = " + d);
System.out.println("mca y= " + y);
}
}
class override
{
public static void main(String a[])
{
mca m = new mca(100,200);
m.display();
}
}
class bca
{
int d;
void get(int x)
{
d = x;
}
void display()
{
System.out.println("Bca = " + d);
}
}
class mca extends bca
{
int y;
mca(int m, int y)
{
get(m);
this.y = y;
}
void display()
{
System.out.println("Bca = " + d);
System.out.println("mca y= " + y);
}
}
class override
{
public static void main(String a[])
{
mca m = new mca(100,200);
m.display();
}
}
No comments:
Post a Comment