The first question has no line number 10, so I can't explain it to you.
This program returns null because when you assign a new HashTest object to obj1, the HashMap is not effected. So when you try to search for a key which has a object of class HashTest with the value 6, it is not found, this is why null is returned.
3, 4 and 5. you just have to remember that you can assign a non-typed collection class to a typed one. This is for backward compatibility as you might use some old code which doesn't have generics.
But you cannot assign a typed collection to another typed collection.
ArrayList<Object> hs = new ArrayList<String
This wont compile. This is because generics are meant for type safety and doing this will make the code unsafe.. Now you will say that how will the code be unsafe. This is how
here we are adding an Integer to a String list. This is possible because we are using a list which has a reference which has a type Object. But actually the list is of type String. Now I don't want to confuse you much here. If you want you can read about generics from sun generics tutorial
, as you seem to be confused..