Results 1 to 9 of 9
Thread: Interface and abstract class
- 06-25-2011, 04:56 PM #1
Member
- Join Date
- May 2011
- Posts
- 3
- Rep Power
- 0
-
Neither. Both. Either.
If you need a more informative answer, you may wish to ask a more informative question by providing context regarding the problem you're trying to solve and details of your current program. You can find more suggestions on how to ask a better question in my link below on how to ask smart questions.
- 06-25-2011, 04:57 PM #3
Which do you think?
db
- 06-25-2011, 05:04 PM #4
Member
- Join Date
- May 2011
- Posts
- 3
- Rep Power
- 0
i think, we can implement more thn one interface but in case of abstract class only one class can extended.Do you have any other idea.
-
- 06-26-2011, 02:21 AM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
With so little information it's hard really to say. When you have methods, you should try to use interfaces over abstract classes(since you can implement many, and only inherit once). If you are only planning to have constants you shouldn't really use an interface. If the class is only going to have constants you may want to consider making a concrete uninstantiable class(something like Math), which has static constants and a private constructor.
Java Code:public class X{ private X(){ throw new IllegalAccessException("Cannot instantiate class"); } public static final int x = ...; //more constants as needed }
It's a bit hard to really give concrete answers though without more information.
- 07-12-2011, 07:51 AM #7
Member
- Join Date
- May 2011
- Posts
- 3
- Rep Power
- 0
Thank you very much to give these information about class and interface....Can you please tell me which one is faster?
- 07-12-2011, 08:44 AM #8
Which do you think?
db
- 07-12-2011, 01:22 PM #9
Its not really an answerable question. Deciding whether to use an Abstract class or an Interface is completely situational. Some times you are better off using an Abstract class and other times you aren't. Programming does not accept a one size fits all solution to problems.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
Similar Threads
-
Abstract Class & interface
By suresh.sa in forum New To JavaReplies: 1Last Post: 10-18-2010, 08:25 AM -
Difference between Abstract class having only abstract method and a Interface class
By Santoshbk in forum New To JavaReplies: 6Last Post: 02-11-2009, 10:51 AM -
Interface and Abstract Class
By kian_hong2000 in forum New To JavaReplies: 1Last Post: 08-27-2008, 02:22 PM -
Interface Vs Abstract Class
By javarishi in forum New To JavaReplies: 5Last Post: 06-15-2008, 05:43 AM -
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


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks