Skip to content

Instantly share code, notes, and snippets.

@rohanBagchi
Created September 3, 2019 03:54
Show Gist options
  • Save rohanBagchi/f48e13f8bcbb059602f92a149ec015a4 to your computer and use it in GitHub Desktop.
Save rohanBagchi/f48e13f8bcbb059602f92a149ec015a4 to your computer and use it in GitHub Desktop.
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