Sunday, 18 December 2022

Write a program by Using abstract class To display Employee Name, Salary , age using printInfo method.



1Abstract Class :

abstract class Base {
    abstract void printInfo();
}

class Derived extends Base {
    void printInfo()
    {
        String name="avinash";
        float salary = 333.3f;
        int  age=21;

        System.out.println(name);
        System.out.println(salary);
        System.out.println(age);

    }
}

class abstraction {
    public static void main(String args[])
    {
        Base b = new Derived();
        b.printInfo();
    }
}


 

No comments:

Post a Comment

GitHub Most Imp Command For Every Developer Learn:

 Top Command for GitHub:  1) git clone 2) git init and git status   3) git add file name  or git add .  4) git commit -m message  5) git rem...