class Employee {
String name;
int salary;
public Employee(String name,int salary) {
this.name = name;
this.salary = salary;
}
public void displayInfo() {
System.out.println("Name: " + name + ", Salary: " + salary);
}
}
class Manager extends Employee {
int teamSize;
public Manager(String name, int salary, int teamSize) {
super(name,salary);
this.teamSize=teamSize;
}
public void displayInfo() {
super.displayInfo();
System.out.println("Team Size: " + teamSize);
}
}
class Developer extends Employee {
private String programmingLanguage;
public Developer(String name, int salary, String programmingLanguage) {
super(name, salary);
this.programmingLanguage = programmingLanguage;
}
public void displayInfo() {
super.displayInfo();
System.out.println("Programming Language: " + programmingLanguage);
}
}
//TIP To Run code, press or
// click the icon in the gutter.
public class Main {
public static void main(String[] args) {
//TIP Press with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
// Upcasting
Employee E1 = new Manager("Nazrul",50000,20);
Employee E2 = new Developer("Mahin",40000,"Java");
// Downcasting
Manager M1 = (Manager) E1;
}
}
}