Q:Could you fill in the blank。
class Employee{
// field
private String name;
private (1) _float__ salary;
// constructor
(2) ________________________________________
// method
public (3) __String____ getName( ){
return name;
}
public float getSalary( ){
return Salary;
}
public (4) ________ compare( (5) _________________ {
(6) ____________________________________
}
}// class Employee
public class EmployeeUI{
public static void main(String[ ] args){
Employee e1 = new Employee(“William”);
Employee e2 = new Employee(“Rchard”);
if(Employee.compare(e1, e2))
System.out.println(“same employee”);
else
System.out.println(“different employee”);
} }//class EmployeeUI
class Employee{
// field
private String name;
private float salary;
// constructor
public Employee(String name)
{
this.name = name;
}
// method
public String getName( ){
return name;
}
public float getSalary( ){
return salary;
}
public static boolean compare(Employee e1,Employee e2 )
{
if(e1.name == e2.name)
return true;
else
return false;
}
}// class Employee
public class EmployeeUI{
public static void main(String[ ] args){
Employee e1 = new Employee("William");
Employee e2 = new Employee("Rchard");
if(Employee.compare(e1, e2))
System.out.println("same employee");
else
System.out.println("different employee");
} }//class EmployeeUI
Output:
different employee
Do ask if any doubt. Please upvote
Get Answers For Free
Most questions answered within 1 hours.