A good answer might be:

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.


More Practice

Non-abstract children must override the abstract methods of their parents. Here is our situation:

class Parent
{
  public abstract int compute( int x, String j);
}

class Child extends Parent
{
   _____________________________________________  // child's compute method
}

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 ChildOverride, 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){ . . . }

 

QUESTION 4:

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?