Results 1 to 8 of 8
Thread: Interfaces
- 12-09-2007, 08:59 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 8
- Rep Power
- 0
- 12-09-2007, 11:59 AM #2
Have a look at this page:
Interface (Java - Wikipedia, the free encyclopedia)
- 12-10-2007, 08:44 AM #3
Senior Member
- Join Date
- Nov 2007
- Location
- Newport, WA
- Posts
- 141
- Rep Power
- 0
Interfaces can be used to tell in implementing class that it NEEDS to have those methods implemented. Since java does not support multiple inheritance (ie. extend more than one object) it is usefull to tell something it needs to conform to a certain standard.
Basicly, lets say you create an interface with a single method void called foo(). In interfaces, methods cannot have bodies, so it will look something like:
Then in your class you can do:Java Code:public interface FooInterface { public void foo(); }
If you tried to compile something like this it will give you an error, because you need the foo() method.Java Code:public class BarClass implements FooInterface { }
I use interfaces mostly when i am creating a complicated class/sublass structure, and want all my code to conform to a certain standard.Java Code:public class BarClass implements FooInterface { public void foo() { // blah } }
A plugin system would be an example of using interfaces.
- 12-11-2007, 03:09 PM #4
Member
- Join Date
- Dec 2007
- Posts
- 8
- Rep Power
- 0
Thank u..
can you suggest me any small real time application on which i can do a project in core Java..
- 12-11-2007, 03:30 PM #5
Kavana, try creating a new thread instead of spamming old threads. In that way, you can find better answers if you select appropriate thread titles.
- 12-11-2007, 03:32 PM #6
Member
- Join Date
- Dec 2007
- Posts
- 8
- Rep Power
- 0
Is it a disadvantage of interface?
It was given as,
A class which implements an interface must either implement all methods in the interface, or be an abstract class.
- since a class which implements an interface has to implement all the methods of that interface, is it not a disadvantage that it has to implement all methods even if we want only some methods to be implemented..
- 12-11-2007, 03:40 PM #7
Member
- Join Date
- Dec 2007
- Posts
- 8
- Rep Power
- 0
i did not understand what you told sir.. did you mean that i should post my queries directly than just replying to their replies.. i am new to this forum so am not much familiar how to use..
- 12-11-2007, 04:28 PM #8
Yes! Your query below is not related to this thread. Go to appropriate forum index and click "New Thread" button, instead of clicking to the "Post Reply" button here.did you mean that i should post my queries directly than just replying to their replies..
can you suggest me any small real time application on which i can do a project in core Java..
Similar Threads
-
interfaces..
By sireesha in forum New To JavaReplies: 5Last Post: 01-16-2008, 05:52 PM -
Using interfaces with Delegation
By Java Tip in forum Java TipReplies: 0Last Post: 12-06-2007, 01:49 PM -
Help, someone clear up Interfaces for me
By mathias in forum New To JavaReplies: 1Last Post: 08-06-2007, 02:26 AM -
Interfaces
By imran_khan in forum New To JavaReplies: 5Last Post: 07-30-2007, 08:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks