Results 1 to 6 of 6
Thread: Interface Vs Abstract Class
- 04-09-2008, 09:55 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 91
- Rep Power
- 0
- 04-09-2008, 10:16 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
In my programming practice, if I want to change something on my design frequently, I go for an interface.
Abstract class used for some common behaviors.
- 04-09-2008, 10:55 AM #3
Member
- Join Date
- Apr 2008
- Posts
- 91
- Rep Power
- 0
Thanks Eranga. Abstract Class Is Clear. In Case Of Interface, you mean to say if the method signature changes frequently, then we need to put it inside an interface? Can you please, brief me please?
- 04-09-2008, 11:15 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yep, you are right. Say I have an interface like this,
In all case I'm looking different implementation, with the same arguments actually. There are large number of such cases can be found in Java.Java Code:interface Test{ boolean isLess(Object a); boolean isSmall(Object a); boolean isEqual(Object a); }
- 06-14-2008, 02:43 AM #5
Member
- Join Date
- Jun 2008
- Posts
- 22
- Rep Power
- 0
Use abstract classes when you want to "force" to derived classes to implement some code.
Use interfaces when you want to define a behavior that can define any class that implement it on different hierarchies. When a class implements an interface is saying "I'm able to do that especific thing". When you subclass a class you are saying "I'm like my parent and more".
Ferran
Ferran
- 06-15-2008, 05:43 AM #6
Similar Threads
-
difference between Abstract and interface
By mrark in forum New To JavaReplies: 3Last Post: 11-07-2009, 04:20 AM -
Can this be done using abstract class??
By romina in forum New To JavaReplies: 6Last Post: 03-02-2009, 12:46 PM -
what is the Priority for execution of Interface class and a Abstract class
By Santoshbk in forum Advanced JavaReplies: 0Last Post: 04-02-2008, 07:04 AM -
Abstract Class
By gapper in forum New To JavaReplies: 4Last Post: 01-31-2008, 01:25 PM -
Abstract Class question
By maa11235 in forum New To JavaReplies: 1Last Post: 01-05-2008, 10:30 PM


LinkBack URL
About LinkBacks

Bookmarks