|
|
|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

04-09-2008, 10:55 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 91
|
|
|
Interface Vs Abstract Class
Can AnyOne Say, When Exactly, We Need To Go For An Abstract Class, And An
Interface? On Basis Of What We Need To Make A Decision?
|
|

04-09-2008, 11:16 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

04-09-2008, 11:55 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 91
|
|
|
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, 12:15 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
Yep, you are right. Say I have an interface like this,
interface Test{
boolean isLess(Object a);
boolean isSmall(Object a);
boolean isEqual(Object a);
}
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-14-2008, 03:43 AM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 22
|
|
|
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, 06:43 AM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 518
|
|
|
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
All times are GMT +3. The time now is 06:40 AM.
|
|
VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org