Results 1 to 4 of 4

Thread: will it compile?

  1. #1
    Expert Member
    Join Date
    Oct 2005
    Answers
    383

    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.

  2. #2
    Expert Member
    Join Date
    Dec 2006
    Answers
    139

    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


  3. #3
    Junior Member
    Join Date
    Apr 2006
    Answers
    3

    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


  4. #4
    Junior Member
    Join Date
    Feb 2007
    Answers
    1

    Re: will it compile?

    hi Masif,

    small correction, an interface can only extend another interface but an interface can not implement another interface.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact