Geeks Talk

Prepare for your Next Interview




will it compile?

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?...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-17-2007
Expert Member
 
Join Date: Oct 2005
Location: india,cochi,bangalore
Posts: 395
Thanks: 2
Thanked 8 Times in 7 Posts
vmshenoy is on a distinguished road
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.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-17-2007
Expert Member
 
Join Date: Dec 2006
Location: India
Posts: 140
Thanks: 0
Thanked 6 Times in 4 Posts
nikhil_rattan is on a distinguished road
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
Reply With Quote
  #3 (permalink)  
Old 01-24-2007
Junior Member
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
masif is on a distinguished road
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
Reply With Quote
  #4 (permalink)  
Old 02-19-2007
Junior Member
 
Join Date: Feb 2007
Location: A.P
Posts: 4
Thanks: 3
Thanked 0 Times in 0 Posts
ramchinnu is on a distinguished road
Re: will it compile?

hi Masif,

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

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes



All times are GMT -4. The time now is 03:13 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved