Wednesday 15 August 2012

java - Implements an interface after object creation -


I was thinking that it is possible to implement an interface for me after the object is created?

I have not found anything for this but this is not really what I am looking for plus it is for Android programming

Is there any way to accept it or else I want to extend the object to add the interface to it?

There is no code because it is a theological question.

You can not apply the interface after being an object. Applying an interface is not the only way you can call the object.

Even if you can, what will happen? By applying an interface, you "define a promise" that you will define the methods present in the interface. Actually your program will not compile even if you do not. So if you want to apply an interface, you have to do it in class definition and you have to define all the methods of the interface. Then you can make classroom examples. You can not change the object's methods, or add to it.


No comments:

Post a Comment