Overriding Methods in Java








import java.lang.*;
import java.io. *;
class base
{
int x;
base(int x)
{
this.x=x;
}
void display()
{
System.out.println("value of x:"+x);
}

}
class driver extends base
{
int x;
driver(int x,int y)
{
super(x);
this.y=y;
}
void display()
{
System.out.println("value of x:"+x);
System.out.println("value of y:"+y);
}
}
class override
{
public static void main(String args[])
{
driver obj=new driver(10,20);
obj.display();
}
}

Post a Comment

1 Comments