Java Multilevel Inheritance Example


Program
class Species{//Parent Class String name3="Species"; } class Bird extends Species{ //Parent Class String name2="Bird"; } public class Parrot extends Bird{ //Child Class String name1="Parrot"; public static void main(String args[]){ Parrot p=new Parrot(); System.out.println(p.name1+" is "+p.name2+". "+p.name2+" is "+p.name3); } }
Input
Output

Similar Program