Develop a program to create a class "Bird" with the data members 'category' and a method 'show()'. Derive a class "Parrot" with the data members 'no_of_parrots' and a method 'show()'. Initialize using constructor and display the information.

class Bird
{
 String category;
 Bird(String c)
 {
  category = c;
 }
 void show()
 {
  System.out.println("Category: " + category);
 }
}
class Parrot extends Bird
{
 int no_of_parrots;
 Parrot(String c, int n)
 {
  super(c);
  no_of_parrots = n;
 }
 void show()
 {
  super.show();
  System.out.println("No of Parrots: " + no_of_parrots);
 }
}
class Exp6_2
{
 public static void main(String[] args) 
 {
  Parrot ob = new Parrot("Pet", 20);
  ob.show();
 }
}

/*  OUTPUT!!!
Category: Pet
No of Parrots: 20
*/
Copyright © LetML. Blogger Templates Designed by OddThemes