Java

Program to Implement Overriding of Methods

By June 4, 2016 November 9th, 2016 No Comments

/**** Java 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();
}
}

Output:





Screenshot (299)

Leave a Reply