/* Polymorphic: The reference-type variable of the parent class refers to the object of the subclass or the reference-type variable of the interface type that points to the object of the interface implementation class. Implementing polymorphism in Relationships: interfaces variables = new interfaces implements the object of the class. The methods of */interface dao{ //interfaces are all non-static methods. So a reference to a parent class is always a static method called with the same name public void add (); public Void delete ();} Interface implementation Class Class userdao implements dao{ public void add () {        SYSTEM.OUT.PRINTLN ("Add Employee success!! "); } public void delete () { system.out.println ("Delete employee success!! "); }}class demo3 { public static void Main (String[] args) { // The polymorphic dao d = new userdao () under the realization relation; // The reference type variable of the interface points to the object of the interface implementation class. d.add (); }}
This article from "Small Fish Blog" blog, declined reprint!
Java Polymorphism 2