OK, basically the question was
Accessor and Mutator Methods Suppose that the class Pet has a variable/field called name that is of type String>
Write an accessor method getName() that returns the value of name Enter your answer in this box
and I wrote the code as following:
public getName(String name)
{
return name;
}
Write a mutator method setName(), with a return type of void that may be used to change the value of name when the pet changes owners. Enter your answer in this box
and i wrote as following:
public void setName(int newName)
{
name = newName;
}
I seem to be confused as I didnt get the mark, the error I got was
Pet.java:9: invalid method
declaration; return type required
public getName(String name)
^ 1 error The output should have been:
getName() works as expected
setName() works
This is what was actually produced:
Exception in thread "main" java.lang.NoClassDefFoundError: Pet
any ideas what wrong with it?