Prepare for your Next Interview
This is a discussion on will it compile? within the Java forums, part of the Software Development category; hi friends I have an interface that is implemented by 100 classes, if I add a method to the interface will my classes compile? How can I fix any errors?...
|
|||
|
will it compile?
hi friends
I have an interface that is implemented by 100 classes, if I add a method to the interface will my classes compile? How can I fix any errors? ![]()
__________________
:) NEVER SAY DIE. |
| Sponsored Links |
|
|||
|
Re: will it compile?
Hi,
All the implementing classes will not compile. An interface is a contractual obligation. By implementing that interface you are guaranteeing that your class will fulfill its contractual obligation. If you add a new method to an interface then, by definition, all classes implementing that interface will have to implement the new method. Regards Nikhil Rattan |
|
|||
|
Re: will it compile?
lets say you have an interface IInterface which is implemented by 100 classes.
Now u wana add a method to the interface but not all of the implemented classes need to add the method. Create another interface lets say ISubInterface implements IInterface Now use any one depending on your requirement. There is no other way to fix ur problem ![]() |