Hello Maan Shenoy,
Guys correct me if I'm wrong.
HashSet<String> hs = new HashSet<String>();
hs.add("scjp");
hs.add("exam");
HashSet<Object> s = new HashSet<Object>();
s=hs;
gives a compiler error because polymorphism does not work with generics. since the reference variable s is TYPED for type object, you can not assign it to hs which is TYPED for type String. The angle bracket information <E> is available at compile time only. The above statement s=hs is like writing
HashSet<Object> s = new HashSet<String>();
which is not allowed. Polymorphism applies to base classes only i.e
Set<Object> s = new HashSet<Object>(); is fine.
if you remove the <Object> from the reference variable declaration, the compiler error is gone

(Same for the Animal case).
The angle bracket information <E> MUST be the same on the left and right side of the = sign.
Hope I'm write and it helped.
Kind Regrads.
Hasnain Javed Khan.