I have a class where I have overridden both the hashCode method as well as the equals method. The equals method behaves as I would expect it to, however the hashCode method
The problem is not with .hashCode(); the problem is that you don't override .equals()!
Look at your prototype:
public boolean equals(Car car)
Now have a look at the documentation for Object...
What you should override is:
public boolean equals(Object obj)
Hence the error. You did implement hashCode correctly, however you use Object's .equals() implementation.