|
|
Home J2EE Concepts JMS Java Language Contact Back Next Bookmark this Page |
Some useful tips related to:
|
Interfaces & Runtime Polymorphism!In article about inheritance basics I mentioned that using interfaces offers great amount of flexibility when it comes to runtime polymorphism. Here are more details. Although we can not instantiate an interface, but we can create an object of an interface and assign reference of any class implementing this interface. Let's assume that we've an interface named IF1 as follows: Notice that the classes may implement any other methods as well; but the interface won't have any knowledge about them. In above example, inf will not be able to call method2. NOTE: Runtime polymorphism is costly in terms of memory consumption, so use it cautiously for performance centric applications. |
|
|
|