Prepare for your Next Interview
|
Welcome to the Geeks Talk 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), respond to polls, upload content and access many other special features. 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 contact us. |
This is a discussion on Difference between interface and abstract class? are they both same within the OOPS forums, part of the Software Development category; Interface is the framework for methods . where only mehod signature and there is no implementation of a method.In Interface every method is abstract method. In abstract class there abstract ...
|
|||||||
|
|||
|
Re: Difference between interface and abstract class? are they both same
Interface is the framework for methods . where only mehod signature and there is no implementation of a method.In Interface every method is abstract method.
In abstract class there abstract method signature is available and which class extend this super class has to implement this abstract method. |
| Sponsored Links |
|
|||
|
Re: Difference between interface and abstract class? are they both same
1)Abstract class is a collection of abstract methods and concrete methods or only abstract methods or only concrete methods
Interface is a collection of only abstract methods 2)the members of the abstract class are public(default),protected,static the members of interface are implicitly public 3)A class can inherit one or more interfaces but a class can inherit only one abstarct class 4)abstract class can add more functiuonality without destroying the child classes in an interface..creation of additional functions will have an effect on its child class due to necessary implementation of interface methods in child class |
|
|||
|
Re: Difference between interface and abstract class? are they both same
abstract class is a signature of class, can't be instantiated .
it having some abstract members(both variables and methods) which are get implemented in to derived classes Interface is heaving all its methods (no any veriables) without implemented and all its methods are defaultly public because they all get implemented in derived classes but in abstract class only some its members may public Last edited by shilpamj; 04-02-2009 at 08:53 AM. |
|
|||
|
Re: Difference between interface and abstract class? are they both same
1) abstract class may or maynot be contain abstract methods,but interfaces must contain abstract methods only
2)abstract class contains both abstract and concrete methods,concrete methods contain static,final and ordinary methods. 3)abstract class contains all concrete or all static methods or all final methods or all abstract methods or combination of all the above. 4)interface tells us what to do?,but not how to do 5)both abstract class and interface particpates in object creation through the concept of dynamic binding. |
|
|||
|
Re: Difference between interface and abstract class? are they both same
Interface:
>It contains only abstract methods . >it contains only constants but not instance variables. abstract: >it contains some abstract methods or concrete methods . >it contains only instance variables.
|
|
|||
|
Hi,
An interface is called as a pure abstract class where non abstract member functions are not allowed but in case of abstract classes we can have both abstract and non abstract member functions based on the requirement... |
|
|||
|
Re: Difference between interface and abstract class? are they both same
a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract.
b) In abstract class, key word abstract must be used for the methodsWhereas interface we need not use that keyword for the methods. c)Abstract class must have subclasses whereas interface can’t have subclasses. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Real time example for abstract class and interface | Geek_Guest | Java | 4 | 04-15-2009 08:20 AM |
| difference between abstract class and interface | manipalreddy.s | Java | 12 | 10-25-2007 07:06 AM |
| Is there any benefit to extend both Interface and abstract class | Geek_Guest | Java | 1 | 06-08-2007 01:54 PM |
| Confusion with ABSTRACT and INTERFACE | Geek_Guest | Java | 2 | 05-07-2007 04:38 AM |
| Difference between Remote & Serializable interface | Geek_Guest | Java | 1 | 04-02-2007 11:15 AM |