Question: class Cat { private String name; private char gender; public Cat() { name = ; gender = ' '; } //End Module public void
class Cat {
private String name;
private char gender;
public Cat() {
name = " ";
gender = ' ';
} //End Module
public void setName(String newName) {
name = newName;
} //End Module
public String getName() {
return name;
} //End Function
public void setGender (char newGender) {
if (newGender == 'F' || newGender == 'M') {
gender = newGender;
} else {
System.out.println("Error: only M or F is allowed for gender, not: " + newGender);
gender = ' ';
} //End If
} //End Module
Write this statement
return gender;
} //End Function
} //End Class
Type the exact text for the line of the Java to replace Write this statement, which is the method header for the method that accesses the gender attribute.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
