Hi,
Its all about
polymorphism. Any variable of type superclass or interface which is implemented by a class (in this case interface Set implemented by TreeSet or HashSet) can refer to any object which implements Set i.e., Set a=new TreeSet(); "a" is a variable of type Set and refering to object of type TreeSet. Here variable "a" is set to be polymorphic, i.e the ability to refer to more than one subclass or class which implements Set interface. One of the feature of polymorphism is to provide the ristricted access to subclass objects. Here using variable "a" you can access only the methods which are declared in the interface Set. In case of class, you can access only the overriden methods.