JAVA Program to make use of Abstract Class

JAVA Program to make use of Abstract Class:

// program to use the Abstarct class and Method

 abstract class Person     // Abstract class
 {
  String name="John";
  int age=25;

  Person(String n, int a)
  {
  name =n;
  age=a;
  }
  abstract void display();    // abstract method
 }


class Employee extends Person
{
   int salary =3000;
   Employee(String n, int a, int s)
   {
    super(n,a);
    salary=s;
   }

   void display()
   {

    System.out.println("The Name of the employee is: "+name);
    System.out.println("The Age of the employee  is: "+age);
    System.out.println("The Salary of the employee is: "+salary);
   }
 }


 class AbstractClass
  {
   public static void main(String args[])
   {
   Employee e = new Employee("John",22, 5000);

   e.display();
   }
  }

OUTPUT:

The Name of the employee is: John
The Age of the employee  is: 22
The Salary of the employee is: 5000

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.