A simple program for java hierarchical inheritance
Java program using eclipse IDE
package javaproject1;
class Birds
{
void display1()
{
System.out.println("Birds have wings and fethers");
}
}
class Crow extends Birds
{
void display2()
{
System.out.println("crow is a bird its color is black");
}
}
class Parrot extends Birds
{
void display3()
{
System.out.println("parrot is a bird its color is green");
}
}
class HierachicalDemo
{
public static void main(String a[])
{
Crow crow=new Crow();
crow.display1();
Parrot parrot=new Parrot();
crow.display2();
parrot.display3();
parrot.display1();
}
}
Short explanation of hierarchical inheritance in java
Comments
Post a Comment