Hi
When you say replace with "the code that takes parameter as Employee"
its actually not overriding of equals(). It is overloading.
And when you add objects to set,
In case 1: valid overriding, with Object as parameter, it returns true.So, the Set doesn't allow duplicate insertion.
In case 2: you are not overriding, means the Object class' equals() method is called which returns false because the objects are different(two objects having same employee name). So, both are added to Set.
Regards
Sucharitha.