A reference variable can be declared as a class type or an interface type.If the variable is declared as an interface type, it can reference any object of any class that impleme
wherever the method signature reside reference of that interface will not give any error. In your example your method sysout() is in interface so reference of the interface will not give any error, but for method displayName() interface reference gives an error. For that you have to use your class reference.