Overriding a method is when a child class overrides the implementation in the parent class that has the same method signature (method name, return value type, parameter names and types). code example
Example: override interface method with different parameters java
public interface Order
{
public boolean greaterThan(Order other);
}
public class AirCraft implements Order
{
private String make;
private int numSeats;
public AirCraft(String make, int numSeats)
{
this.make = make;
this.numSeats = numSeats;
}
public String getMake()
{
return make;
}
public int getNumSeats()
{
return numSeats;
}
@Override
public boolean greaterThan(Order other)
{
AirCraft x = (AirCraft)other;
return getNumSeats() > x.getNumSeats();
}
public String toString()
{
return make + " -> " + numSeats;
}
}