Last active
August 19, 2019 02:54
-
-
Save hakaneroztekin/3b5ce1e1991762d1a6166893f1f8f3a4 to your computer and use it in GitHub Desktop.
This file contains 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
class Employee { | |
String name; | |
Integer salary; | |
public Employee() { | |
name = "Daniel"; | |
salary = 120000; | |
} | |
public void printDetails(){ | |
System.out.println(name + " " + salary); | |
} | |
} | |
class JavaEngineer extends Employee { | |
String language; | |
public JavaEngineer() { | |
language = "Java"; | |
} | |
public void printLanguage(){ | |
System.out.println(language); | |
} | |
} | |
public class TestInheritance { | |
public static void main(String ... args) { | |
JavaEngineer javaEngineer = new JavaEngineer(); | |
javaEngineer.printDetails(); // Daniel 120000 | |
javaEngineer.printLanguage(); // Java | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment