Created
June 29, 2021 04:02
-
-
Save Ram-1234/d056b48b31d90d68cefc20913ca8f5a8 to your computer and use it in GitHub Desktop.
Inheritence in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. | |
//It is an important part of OOPs (Object Oriented programming system). | |
class Employee{ | |
float salary=40000; | |
} | |
class Programmer extends Employee{ | |
int bonus=10000; | |
public static void main(String args[]){ | |
Programmer p=new Programmer(); | |
System.out.println("Programmer salary is:"+p.salary); | |
System.out.println("Bonus of Programmer is:"+p.bonus); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment