No. It is an error if a child defines a method with the same signature as a parent method, but with a different return type.
Non-abstract children must override the abstract methods of their parents. Here is our situation:
Examine each of the following choices for filling the blank. What will the new definition do? Override the parent's method, define an additional method, or be an error? (If the choice defines an additional method, assume that the required method is also defined.)
method defined in Child | Override, Additional, or Error? |
---|---|
public int compute( int x, String j ){ . . . } |
|
public int compute( int stuff, String str ){ . . . } |
|
public int Compute( int x, String j ){ . . . } |
|
public int compute( String j, int x){ . . . } |
|
public double compute( int x, String j){ . . . } |
Say that a child class defines just one method, and that method has the same name as the parent's abstract method, but with a different signature. Must the child class be abstract?