package four; public class Employee { public String name; public int salary; public Employee() { name ="Unknown"; salary = 0; } public Employee(String n,int s) { name = n; salary = s; } void showEmployee() { System.out.print("name: "+name+" "); System.out.print("salary: "+salary+" "); } class Manager extends Employee { public String position; public Manager() { position="unknown"; } public Manager(String n,int s,String p) { super(n,s); position=p; } void showManager() { System.out.printIn("position: "+position); } } class Demo7_ 2 { public static void main(String args[]) { Manager m1=new Manager(); Manager m2=new Manager("Bob",4000,"Sales Manager"); m1.showEmployee(); m1.showManager(); m2.showEmployee(); m2.showManager(); } }
here is my Java program.I don't know what's wrong, I can't run it.
package four;
public class Employee
{
public String name;
public int salary;
public Employee()
{ name ="Unknown";
salary = 0;
}
public Employee(String n,int s)
{ name = n;
salary = s;
}
void showEmployee()
{
System.out.print("name:"+name+" ");
System.out.print("salary:"+salary+" ");
}
}
class Manager extends Employee
{
public String position;
public Manager()
{ position="unknown";
}
public Manager(String n,int s,String p)
{ super(n,s);
position=p;
}
void showManager()
{
System.out.println("position:"+position);
}
}
class Demo7_2
{
public static void main(String args[])
{
Manager m1=new Manager();
Manager m2=new Manager("Bob",4000,"Sales Manager");
m1.showEmployee();
m1.showManager();
m2.showEmployee();
m2.showManager();
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images