Created
September 3, 2019 03:54
-
-
Save rohanBagchi/f48e13f8bcbb059602f92a149ec015a4 to your computer and use it in GitHub Desktop.
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
class Employee { | |
String name; | |
int age; | |
String emp_id; | |
public Employee(String name, int age, String emp_id) { | |
this.name = name; | |
this.age = age; | |
this.emp_id = emp_id; | |
} | |
public String sayName() { | |
return "My name is "+this.name; | |
} | |
} | |
class Accountant extends Employee { | |
String role; | |
public Accountant(String name, int age, String emp_id) { | |
super(name, age, emp_id); | |
this.role = "accountant"; | |
} | |
} | |
public class Main | |
{ | |
public static void main(String[] args) { | |
Accountant a = new Accountant("Rohan", 30, "11234"); | |
System.out.println(a.sayName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment