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