Java Reference
In-Depth Information
This statement:
A.
Creates an EmpFrame object
B.
Passes the Employee variable (emp) to EmpFrame's constructor
C.
Creates an EmpFrame variable called ef
D.
Assigns the EmpFrame object to ef
EmployeeApp's executable statements should look like the following:
package c3;
public class EmployeeApp {
public static void main(String[] args) {
Employee emp = new Employee( new String("Mary Worker"));
EmpFrame ef = new EmpFrame(emp);
}
}
2.
Save the EmployeeApp source code and verify there are no errors.
The following steps all concern changes to the Employee class source code:
3.
Delete the two import statements.
4.
Remove the following statement from the Employee constructor:
this .displayName();
5.
Delete the displayName method.
We want to define the String empName as a property. As a reminder, the steps for defining a property are:
A.
Create a private variable
B.
Define a getter method to return the private variable value
C.
Define a setter method to:
accept a value for the private variable
validate the value
if the value is valid, set the private variable to the value passed to the setter method
For simplicity's sake, we will not define any edits to validate the data.
6.
Change the String empName to a private variable.
7.
Add a public setName method that:
A.
Returns void
B.
Accepts a String variable called name as a parameter
C.
Sets the private variable empName to name
Search WWH ::




Custom Search