Write a Java Program to implement inheritance and demonstrate use of method overriding.
Program Code:
import java.lang.*;
class A
{
void display()
{
System.out.println("This is from class A ");
}
}
class B extends A
{
void display()
{
System.out.println("This is from class B ");
}
}
class AB
{
public static void main(String arg[])
{
B obj=new B();
obj.display();
}
}
Output:
This is from class B
Post A Comment:
0 comments: