If im correct, we can't overload based only on return type. But the example from K&B shows that it is possible and it is said to be an OVERRIDE !
How is it possible an overriden method having different return types ??
referring to the
getRental method in both classes
class Rental
{
private List rentalPool;
private int maxNum;
public Rental( int maxNum, List rentalPool )
{
this.maxNum = maxNum;
this.rentalPool = rentalPool;
}
public Object getRental()
{
return rentalPool.get(0);
}
}
class CarRental extends Rental
{
public CarRental( int maxNum, List<Car> rentalPool )
{
super( maxNum, rentalPool );
}
public Car getRental() // how can it be an override ??
{
return (Car)super.getRental();
}
}