Super class variables not printing through sub class
- by Abhishek Singh
Can u tell me why this code is not displaying any result on the console.
class employee {
protected String name;
protected double salary;
protected String dob;
public employee(String name, double salary, String dob) {
this.name = name;
this.salary = salary;
this.dob = dob;
}
public employee(String name, double salary) {
this.name = name;
this.salary = salary;
}
}
public class Manage extends employee {
String dept1;
public Manage(String name, double salary, String dob, String dept1) {
super(name, salary, dob);
this.dept1 = dept1;
}
public Manage(String name, double salary, String dept1) {
super(name, salary);
this.dept1 = dept1;
}
public static void main(String args[]) {
employee e = new employee("Vikas", 122345);
employee e2 = new employee("Vikas", 122345, "12-2-1991");
Manage m = (Manage) new Manage("Vikas", 122345, "Sales");
Manage m2 = new Manage("Vikas", 122345, "12-2-1991", "sales");
m.display();
m2.display();
}
public void display() {
System.out.println("Name " + name);
System.out.println("Salary " + salary);
System.out.println("Birth " + dob);
System.out.println("Department " + dept1);
}
}