• RELEVANCY SCORE 5.48

    DB:5.48:Why Interface?Differnce Between Interface And Abstract Class d3




    why we go for interface? what is the difference between interface and abstract class?

    can anyone plz explain with clear picture.

    DB:5.48:Why Interface?Differnce Between Interface And Abstract Class d3

    Look at his profile. He's nothing but a homework dumper anyway. Someone to be ignored.

  • RELEVANCY SCORE 4.83

    DB:4.83:Abstract Class 13




    Difference between abstract class and interface
    use of abstract class

    DB:4.83:Abstract Class 13

    This question has been asked here about a billion times:

    http://search.java.sun.com/search/java/index.jsp?qt=interfacenh=10qp=st=11rf=0since=country=language=charset=variant=col=javaforums

  • RELEVANCY SCORE 4.40

    DB:4.40:Difference Between Interface And Abstract Class? x1




    Hi,

    Can u plz explain
    at what scenarios we use interface and abstract class.?

    Thanks,
    B.Maruthi

    DB:4.40:Difference Between Interface And Abstract Class? x1

    If you had read the FAQ at the top of the forum home
    page you wouldn'y have bothered to ask this
    question.Anyways heres the link

    Read the question number 13 in this link

    http://access1.sun.com/FAQSets/newtojavatechfaq.htmlnice

  • RELEVANCY SCORE 4.12

    DB:4.12:Core Java 83


    what is differernce between abstract class and interface?

    DB:4.12:Core Java 83

    jwenting wrote:
    maybe an attempt at counting only posts which make any kind of sense at all?Where did the '1' come from then?

  • RELEVANCY SCORE 4.12

    DB:4.12:Abstract Vs Interfaces sx


    hi i am looking for the difference between abstract classes and interfaces. i have refered a couple of books but nothing seems to satisfy me. and another thing when to use an abstract class and when to use an interface( other than multiple inheritence)

    thanks

    DB:4.12:Abstract Vs Interfaces sx

    In my opinion, Java sun programmers construct
    abstract classes in order to prevent some of the
    disadvantages of interfaces such that using only
    empty bodied method.It is a joke do not take it serious but it is really true that they construct abstract classes in order to prevent some of the disadvantages of interfaces

  • RELEVANCY SCORE 4.12

    DB:4.12:Difference Between Interface And Abstract Class zk


    hai

    please tell me what is the difference between interface and abstract class?

    when i want use inteface? when i want use abstrct class?

    give me the simple example for that?......

    DB:4.12:Difference Between Interface And Abstract Class zk

    This thread is moved from "JavaServer Pages (JSP) and JSTL" to here.

  • RELEVANCY SCORE 4.05

    DB:4.05:When To Use Abstract Class And Interface 3z


    What is the scenario to use abstract class and interface

    DB:4.05:When To Use Abstract Class And Interface 3z

    Read this too, if you have time. :)
    http://java.sun.com/developer/JDCTechTips/2001/tt1106.html#tip2

  • RELEVANCY SCORE 4.05

    DB:4.05:Abstract Class And Interface 17



    Please tell me what is Abstract Class and Interface. Please explain with help of simple example and also tell me difference between them.

    DB:4.05:Abstract Class And Interface 17


    hi

    i will suggest u to refer some basic java book , to clear ur basic concept of OOPS , because these principal remain same for all languages that follow OOPS concept .

    and under standing these with java is easier then with ABAP .

    Abstract Class

    class which have atleast 1 method which is declared only , (no definition is given for it in this class is mentioned as Abstract Method )

    and that class is defined as Abstract class

    Interface :

    only declaration of method done here , no method will be defined here , class which will implement this interface will give definition .

    Diff. b/w Abstract Class and Interface :

    ABS Class can have method with there definition , but one method should be there with declartion only.

    Interface will have all method with out definition .

    hpoe this help u .

    reward if helpful.

  • RELEVANCY SCORE 4.05

    DB:4.05:Interface Relation Between Servletrequest And Httpservletrequest 1z


    a newbie question, both are interface, and

    public abstract interface javax.servlet.ServletRequest extends java.lang.Object

    public abstract interface javax.servlet.http.HttpServletRequest extends java.lang.Object implements javax.servlet.ServletRequest

    Why not interface javax.servlet.http.HttpServletRequest direct extends interface javax.servlet.ServletRequest ?

    DB:4.05:Interface Relation Between Servletrequest And Httpservletrequest 1z

    the signature of HttpServletRequest class is

    public abstract interface HttpServletRequest
    extends ServletRequest

    NOT

    public abstract interface javax.servlet.http.HttpServletRequest extends java.lang.Object implements javax.servlet.ServletRequest

  • RELEVANCY SCORE 4.04

    DB:4.04:Interface And Abstract Class dc


    why we have constructor for abstract class and not for interface,

    DB:4.04:Interface And Abstract Class dc

    Simpler reason: interfaces have no implementation. Period.

  • RELEVANCY SCORE 4.04

    DB:4.04:Diff. Between Interface And Abstract Class 8j


    hi,
    Can any one tell me about diff between interface and abstract class in practical way.advanced thanks for ur response.
    -PVMVS

    DB:4.04:Diff. Between Interface And Abstract Class 8j

    An interface is a way to specify a set of abstract methods that you want a class to implement. The big deal is that the compiler will check that the methods are in fact provided by the class.

    Interfaces almost always represent a view that has nothing to do with the class hierarchy. It could for example be a specific way to access data, like an iterator. Iterators have seldom anything to do with the logical class design. It's just a common way to iterate through the elements of any class.

  • RELEVANCY SCORE 4.04

    DB:4.04:Interface Vrs Abstract Class ps


    why would i during design choose for an interface or an abstract class. I cant understand the need for both ?

    To make a class a partially implemented, its has to be abstract.
    I can choose to create a complete Interface heirarchy and simulate the same.........

    Can people clarify why Interface and why abstract.

    Ps: I know difference between both but I want to justify myself why I wud go for abstract class or interface

    Looking for ur inputs

    DB:4.04:Interface Vrs Abstract Class ps

    why would i during design choose for an interface or
    an abstract class.If there was no abstract you would have to use overriding to accomplish the same thing. But abstract is stronger because you clearly state your intention of leaving the implementation to a subclass. Overriding isn't enforced, the subclass always has a choise. In short, using abstract the superclass rules, using overriding the subclass rules.

    So the big deal is when to use abstract and when to use overriding. Interfaces don't have anything to do with that! Interface are used when you want to ensure a class has a certain functionality that is not a natural part of the normal class hierarchy. It's often a common way to access data, like for example iteration.

  • RELEVANCY SCORE 4.04

    DB:4.04:Why We Use Interface? c9


    I appeared one of my interviews.The Interviewee asked me a question that

    Suppose one is abstract class and one is interface.
    All the methods of abstract class are abstract.
    Then on this level what is the difference between abstract
    and interface and why we use interface. I could not answer properly.
    Please guide me the actual difference between Abstract class and Interface.
    Thanks

    DB:4.04:Why We Use Interface? c9

    google is your friend! Dear You are also my friend ;)

  • RELEVANCY SCORE 4.04

    DB:4.04:Abstact Class And Interface s9


    Hi,

    Any One Can Let me know the exact diff. Between the Abstract class and Interface.

    With
    BAbu

  • RELEVANCY SCORE 4.04

    DB:4.04:Abstract Class And Interfaces xz


    Hi Recently

    I attended a Interview ,Interviewer asked me what is difference b/w abstract and interface.

    I cud give answer ,,he said what if abstract class has all abstract methods.in this situation is ther any difference between abstract class and interface..

    i said there will be no difference in making all methods abstract and it is similar to interface.the only difference is at one point of time u can have a class can inherit only one abstarct class whereas interface u can have more than one interface....

    I want to know is my answer is right r not..please suggest is it correct and if any other ans please do reply

    With Regards
    Mahender
    Mahender

    DB:4.04:Abstract Class And Interfaces xz

    Stepping away from purely technical differences, there are some more fundamental ones.First there is a semantic difference. A base class says that any derived classes have an is a relationship with the base. For example you could have a base class such as Stream because derived classes are streams, but you wouldn't have a base class such as Serializable because you couldn't say that a derived type is a Serializable.Secondly there is the versioning problem. With an abstract base class you can add non-abstract members in future versions without breaking any existing functionality (save for possibly name collisions) because the base class provides the implementation. With an interface you can never add members because you will break any existing implementors. http://gregbeech.com/blogs/tech

  • RELEVANCY SCORE 4.00

    DB:4.00:Abstract Class Vs Interface ? 9d


    hi all,

    can anybody help me.

    if i have an abstract class (full of abstract method definitions) and an interface(having same definitions).

    Now the question is in which situation we go for an ABSTRACT CLASS with full of abstract method definitions and in which situation we go for an INTERFACE.

    and other differences between ABSTRACT CLASSES and INTERFACES except Multiple Inheritence ?

    DB:4.00:Abstract Class Vs Interface ? 9d

    Hi,
    All the variable inside the interface are static and final(You can't change it).While in case of abstract class it is not so. And in abstract class you can have concrete method also while in interface all the method must be non concrete So its depends on your requirement.

    Regards,
    Alok

  • RELEVANCY SCORE 4.00

    DB:4.00:Abstract Class And Interface z1


    What is most important thing about abstract class and interface.

    When to use abstract class and interface.

    DB:4.00:Abstract Class And Interface z1

    The interface is like an agreement where the class
    which implements the interface promises to write the
    implementation code for all the functions in the
    interface.Same for an abstract class, only, rather than "all the methods" it's "all the abstract methods." Of course, you could turn around and usethat wording for interfaces too, but in that case it means "all the methods" since interfaces' methods are all abstract.

  • RELEVANCY SCORE 3.98

    DB:3.98:What Is The Difference Between Abstract Class And Interface jf


    Hi,
    Can you please tell me the differences between Abstract class and Interface.
    In which scenarios we have to use Abstract class and in which scenarios should use Interface.

    Thanks and Regards
    Kranthi

    DB:3.98:What Is The Difference Between Abstract Class And Interface jf

    http://stackoverflow.com/questions/761194/interface-vs-abstract-class-general-oo

  • RELEVANCY SCORE 3.96

    DB:3.96:Diff Interface And Abstract Class af


    I would like to know difference between Interface and abstract class.

    I know simple differences ... like with iterface u can achieve multiple inheritence and with abstract class can have method definition.

    It is said that with interface u achive less coupling, while its other way with abstract class.

    What exactly does this mean ?? how this is implemented programatically ??

    Cheers,
    Rana

    DB:3.96:Diff Interface And Abstract Class af

    You're not saying this is a reason not to use interfaces, are
    you?I haven't (yet) had this situation happen to me as a result of evolution of my APIs but I would think that's one thing to consider when choosing whether you should go with an abstract class or an interface for a supertype.

  • RELEVANCY SCORE 3.96

    DB:3.96:Who Can Tell The Difference Of The Abstract Interface Class? 79


    someone ask me that he had a abstarct interface class, such as :
    public abstract interface Book{
    }
    I was comfused, who can tell me why use it?

    DB:3.96:Who Can Tell The Difference Of The Abstract Interface Class? 79

    http://java.sun.com/docs/books/tutorial/java/interpack/interfaceDef.html

    Scroll down to the bottom.

    Drake

  • RELEVANCY SCORE 3.89

    DB:3.89:Interface And Abstract Class Difference 18


    An interface can be used in such a way that we don't know the class of object assigned to a reference of that interface type until runtime. Can we use the abstract class in a similar way too?

    The difference between an abstract class and interface can be listed as
    1. Interface can not have implementation of any method
    2. The usage of interface and class is one other difference
    3. What other differences we have?

    DB:3.89:Interface And Abstract Class Difference 18

    941767 wrote:
    Here we have some more difference...Differences that mean nothing to an experience professional programmer.

  • RELEVANCY SCORE 3.87

    DB:3.87:Abstract Class And Interface Use 1k


    hi

    i am asking some stupied questions. plz can any one tell me

    1) what is interface and abstract class ? one example?
    2) when do u go for interface and when do u go for abstract class?
    3) what is exact difference between abstraction and encapsulation?

    thanks in advance

    DB:3.87:Abstract Class And Interface Use 1k

    Mahaboob wrote:
    hi

    i am asking some stupied questions.I agree.

    plz can any one tell meHere's a much better idea. You go do some basic research on these questions which have been asked 1,000,000,000 times previously and then tell us what you think. Then we can have a lively discussion about your ideas.

    'kay?

    And just to get you started in the right direction here's something you can review that will answer part of or all of your questions [_http://java.sun.com/docs/books/tutorial/java/index.html_|http://java.sun.com/docs/books/tutorial/java/index.html]

  • RELEVANCY SCORE 3.80

    DB:3.80:Difference Between Pure Abstract Class And Interface? 89


    hi,
    i just want to know the difference between pure abstract class(as same as interface- no implementation of methods) and interface

    Thanks,

    DB:3.80:Difference Between Pure Abstract Class And Interface? 89

    A very nice and detailed article on this code project link (posted by Magnus).

  • RELEVANCY SCORE 3.80

    DB:3.80:Abstract Class Cannot Be Override From An Interface Class sd


    Please help:(
    how to make an existing class to be abstract, so that it can override from an interface class?

    DB:3.80:Abstract Class Cannot Be Override From An Interface Class sd

    In my previous post, I implemented the isLargerThan(Relatable other) method as an example*.
    After a few searches, I've finally found out what you need : [*Implementing an Interface*|http://v1.dione.zcu.cz/java/docs/tutorial/java/IandI/usinginterface.html] .
    You don't have to include the lines of my example to the lines of the tutorial example.

    Edit : My sight is a real problem. I didn't notice you posted the tutorial example.

    Edited by: Chicon on Sep 20, 2009 10:21 AM

  • RELEVANCY SCORE 3.79

    DB:3.79:Differance Between Abstract Class And Interface 7s


    Whats the main differance between abstract class and Interface and where I can use abstract class and where I can use Interface

    DB:3.79:Differance Between Abstract Class And Interface 7s

    Refer to
    http://www.javaworld.com/javaworld/jw-09-2001/jw-0921-interface.html

  • RELEVANCY SCORE 3.77

    DB:3.77:Interface And Abstract Class dd


    what is the difference between interface and Abstract class?
    What are the situations we have to go for interface and Abstract class?

    DB:3.77:Interface And Abstract Class dd

    Neither an abstract class nor an interface can be instantiated (meaning you cannot create the object directly with the "new" keyword). They are both similar in that they have abstract methods. (Technically, you can create an abstract class with no abstract methods, but I would question the utility of making that class abstract in the first place).

    The two main differences are the following:

    Implementation: An abstract class can implement methods, since it is a class. An interface can never implement any methods, it only declares their signatures.Inheritance: A given class can implement an unlimited number of interfaces. A class can only extend one class. In general, I use the following rules of thumb when deciding (other developers may have differing opinions):

    Given the choice, use an interface. Since you can implement an unlimited number of interfaces, they are not as restricted, from a class hierarchy perspective. If you have several classes with the same instance (class) variables declared and several methods that all accomlplish the same thing (normally, they will even have segments of code copy-pasted between classes), then re-factor the common variables and code into an abstract class. When using interfaces, always consider delegation. Delegation is something like the following:interface IFoo {
    abstract public void bar();
    }

    public class FooDelegate {
    final public void bar() {
    // Default implementation goes here
    }
    }

    public class FooImpl implements IFoo {

    final public void bar() {
    new FooDelegate().bar();
    }
    }

    The advantage of delegation is that you can write a "helper" that contains the implementation, and then the classes that actually implement the interface can simply use the helper (e.g., delegate the implementation to another class).

    - Saish

    "My karma ran over your dogma." - Anon

  • RELEVANCY SCORE 3.75

    DB:3.75:Public Abstract Interface Filterconfig pf


    public abstract interface FilterConfig

    what is this class actually . is it abstract class or interface?

    DB:3.75:Public Abstract Interface Filterconfig pf

    interfaces are abstract because you cannot
    instantiate them.

    like you cant instantiate a abstract class.It's the other way around. You cannot instantiate them because they're abstract. Only what's fully concrete can be instantiated.

  • RELEVANCY SCORE 3.75

    DB:3.75:Abstract Calss Vs Interface af


    hi all,

    what are the pros and cons of abstract calss and interface?
    when to use abstract class and when to use interface???

    thanks.

    DB:3.75:Abstract Calss Vs Interface af

    Well.. this is very basic question and asked many times. Googling this question may give you good results...

  • RELEVANCY SCORE 3.75

    DB:3.75:Difference Between Interface And Abstract Class zm


    What is the differrence between an abstract class and an interace? and when would you use one over the other?

    DB:3.75:Difference Between Interface And Abstract Class zm

    What is the differrence between an abstract class and
    an interace? and when would you use one over the
    other?To (over-)summarise:
    An interface defines what you want to do, but doesn't tell you how to do any of it.
    An abstract class may define some of how to do it, but not necessarily all.

    RObin

  • RELEVANCY SCORE 3.75

    DB:3.75:Re: What Is The Difference Between An Interface And An Abstract Class? 1a


    8000 views already wow.

    DB:3.75:Re: What Is The Difference Between An Interface And An Abstract Class? 1a

    filestream wrote:
    As the two famous politicians, Jonathan Curry and Larry Craig are wont to say, "Glad I could serve you."

    Of course, each says it in entirely different situations but we're not here to discuss that. The members of the forums are happy just knowing that we've cleared 1 doubt.Now that you mention it, I take a wide stance in the interface/abstract class issue.

  • RELEVANCY SCORE 3.75

    DB:3.75:Abstract Class Vs Interface 9d


    Hi

    I was just wondering what is the advantage of using an abstract class over interface. In what situation, using an abstract class is more suitable than using interface? and vice versa?

    DB:3.75:Abstract Class Vs Interface 9d

    This question has been asked and answered a million times. For instance, see this thread: http://forum.java.sun.com/thread.jsp?forum=31thread=352322

  • RELEVANCY SCORE 3.73

    DB:3.73:Difference Between Abstract Class And Interface ca


    Hi everyone,

    CAn anyone explain why the following happen????

    --------------------------------------------------------------------------------
    Abstract class can have a constructor, Interface cannot.
    Abstract class can have static methods, Interface cannot.
    --------------------------------------------------------------------------------

  • RELEVANCY SCORE 3.73

    DB:3.73:Abstract Class &Amp; Interface jp


    In which situation we use Abstract Class and in which situation we use Interface?

    DB:3.73:Abstract Class &Amp; Interface jp

    In which situation we use Abstract Class and in which
    situation we use Interface?It's a frequently asked question so search the forums.

    One answer is that from a pure typing perspective it doesn't matter because they're equal. The difference is that an abstract class can carry implementation, something an interface cannot. So pick the abstract class when you consider that beneficial.

  • RELEVANCY SCORE 3.71

    DB:3.71:Difference Between Abstract Class And Interface ? fz


    CAN ANY BODY TELL ME THE DIFFERENCE BETWEEN THE ABSTRACT CLASS AND INTERFACE ?

    DB:3.71:Difference Between Abstract Class And Interface ? fz

    - An abstract class is a class that can not be instantiated but that can contain code, i.e. it gives you the ability to specify default implementations of methods.

    - An interface only contains methods but does not contain any code and you need to implement all the methods defined in the interface.
    - Interfaces may be multiple-inherited, abstract classes may not
    http://www.codeproject.com/Articles/11155/Abstract-Class-versus-Interface
    http://stackoverflow.com/questions/56867/interface-vs-base-class

  • RELEVANCY SCORE 3.71

    DB:3.71:Interfaces And Abstract Classes 73


    can anyone pls tell me where exactly an abstract class is used and where exactly an interface is to be used.

    i think the main difference between an abstract class and an interface is that an interface will have all the abstract methods whereas an abstract class can have one or more abstract methods--- if i am not wrong.
    anything to add? -- pls let me know on this....

    and also how they might be useful for us....

    DB:3.71:Interfaces And Abstract Classes 73

    The differences are already quoted. In addition of that
    the abstract class will come in the class/system hierarchy, but interface will not.

  • RELEVANCY SCORE 3.71

    DB:3.71:Java Interfaces And Abstract Classed fc


    what is the difference between interface and abstract class?

    DB:3.71:Java Interfaces And Abstract Classed fc

    I suggest you try writing some code and see.

  • RELEVANCY SCORE 3.68

    DB:3.68:Simple Query ac


    Difference between Abstract class and interface with practical example

    DB:3.68:Simple Query ac

    You are right; it was a simple query. (and I don't mean "simple" as in lacking complexity.)

  • RELEVANCY SCORE 3.68

    DB:3.68:Interface And Abstract Class ad


    Why can't we declare a static method in Interface but it's possible in abstract class?

    DB:3.68:Interface And Abstract Class ad

    Because an interface is simpler than an abstract class.
    Normally you would put a static method like this into a utility class with a private constructor. see the Math class.

  • RELEVANCY SCORE 3.68

    DB:3.68:Diference Between Abstract Class And Interface cp



     
    Hi,
     
    I had a doubt on basic concept of interface and abstract class.
     
    I had idea of wht is interface and abstract class but there is case ,can any do justification on these case is
     
    Abstract class is a clas where some methods r defined and some are abstract methods.
    Interface is where all methods are abstract .
     
    but what happen if i try to maintaince all methods in abstract class as abstract which is equivalent to interface.?
     
    We go for abstract class if want to extend functionality of class.For interface if we wanna implement a new implementation.
     
    is there any other difference apart from this and other issues if we try to have all methods abstract .
     
     
    With regards
    Mahender

    DB:3.68:Diference Between Abstract Class And Interface cp

    Hi,
     
    Thnx for giving info.Actually iam looking for projct development point of view..In whihc cases i do go 4 developing abstract classes  other interfaces

  • RELEVANCY SCORE 3.68

    DB:3.68:Abstract Class And Interface???? 39


    hi all, i would like to know the difference between abstract class and interface....could anybody enlighten me on this....

    DB:3.68:Abstract Class And Interface???? 39

    P.S. don't be a loser an put up multiple posts, especially on something so easy to do a search on.

  • RELEVANCY SCORE 3.67

    DB:3.67:Abstract Class-Interface - Usage 71


    hai
    Give me details regarding the suituation of using
    1. Abstract class
    2. Interface

    DB:3.67:Abstract Class-Interface - Usage 71

    Basically an interface is a set of methods a class can promise to implement. An interface often expresses some aspect of a class that isn't related to the class hierarchy itself (that Dog, Duck and Cat extends Animal kind of stuff). It's often a common way to access stored objects like for example the Enumeration and Iterator interfaces.

    If a class has promised to implement an interface but doesn't, it becomes abstract. A class also becomes abstract if some methods are declared abstract. In both cases the class must be declared abstract and the actual implementation of the abstract methods is left over to subclasses.

    The reason for declaring a method abstract is one of design. The abstract class is often made to contain general information about something, and its subclasses are expected to fill in specific details by implementing the abstract methods. For example Animal can leave noise() abstract and let Dog, Duck and Cat provide the actual sounds.

  • RELEVANCY SCORE 3.65

    DB:3.65:Difference Between Interface And Abstract Interface 8a


    What is the difference between the following?

    interface Sample{

    }and

    abstract interface Sample{

    }Please explain it with an example.

    DB:3.65:Difference Between Interface And Abstract Interface 8a

    An all the interface's methods are public and abstract, even if you don't declare them as such. And all it's variables are public, static final, even if you don't declare them as such.

  • RELEVANCY SCORE 3.64

    DB:3.64:Difference Between Interface And Abstract Class a1


    Hi sirs,

    Give me the differences between interface and abstract class
    and when we go for interfaces and abstract class in developing an application

    DB:3.64:Difference Between Interface And Abstract Class a1

    An interface is a 100% abstract class, which means it doesn't contain any code, just method names and signatures. You use abstract classes when you want some code to be shared among the inheritors.

    The advantage with interface is that a class can implement as many interfaces as you like, while it can only extend one (abstract) class.

    So, you use interfaces when you need to extend other classes or doesn't want any code shared, and abstract classes when you don't want to extend other classes, and would like to share some code.

  • RELEVANCY SCORE 3.62

    DB:3.62:Abstract Class And Interface 18


    what is the difference between abstract class and interface

  • RELEVANCY SCORE 3.62

    DB:3.62:What Is The Main Difference Between Interface And Abstract Class 37


    Hi ,

    Please help on this ..

    Regards,
    vij

    DB:3.62:What Is The Main Difference Between Interface And Abstract Class 37

    All the methods declared inside interface should be abstract

    All the methods declared for an interface are abstract, by definition.

    but in case of abstract class at least one method should be abstract

    No. An abstract class is not required to have any abstract methods. It's not even a "should".

    Abstract class must be extended abstract ()
    methods generally contain only declaration part
    without definition part.
    No "generally" about it, as there are no exceptions. Abstract methods do not have a declared body, by definition.

    ~

  • RELEVANCY SCORE 3.61

    DB:3.61:Re: Interface And Abstract pm


    An interface should be used to define a protocolfor
    usage of all implementing classes where as an
    Abstract class should be used when some of the
    functionality is clearly defined but some on the
    other hand is well "abstract"Indeed. Often enough, I use both an interface and
    an abstract class.Likewise.

    I don't know that I've ever "chosen between" an interface and an abstract class. To me they serve completely different roles, often working together. It's like choosing between toast and milk--they're not even both candidates for the same job.

    DB:3.61:Re: Interface And Abstract pm

    ..[if you] want to add a whole set of functionalities
    which are going to affect a greater chunk of your code,
    then it can, and should be, achieved using an interface
    which can then be implemented into the respective
    classes with minimum code alteration.Minimum code alteration? Wouldn't you have to add "implements NewInterface" after each class name, and then in each class implement all the methods in the interface? It doesn't appear that an interface achieves "minimum code alteration." Couldn't you forgo using an interface and just implement the methods in each class? That would save you from having to write "implements NewInterface" after each class name? Therefore, there would be less code alteration by not using an interface.

    This functionality can't be achieved using
    an abstract class.Why not? You could implement all the interface methods in the base classes, and they would be inherited automatically by all the subclasses--with the result being much less code alteration.

    It doesn't sound like code alteration can be used as the basis for deciding between using an interface or an abstract class.

    arunts,

    I've never read a satisfactory explanation of the differences between interfaces and abstract classes, and the subject crops up here regularly.

  • RELEVANCY SCORE 3.61

    DB:3.61:Abstract Class sj


    hello

    why cant we create an object to Abstract class and interface ?
    And if we cant create object how can we can create reference variables to both abstract and interface?

    DB:3.61:Abstract Class sj

    kirn291 wrote:
    how can we can create reference variables to both abstract and interface?I can create a variable of type List (interface), like so

    List _myList = new LinkedList();

  • RELEVANCY SCORE 3.60

    DB:3.60:Difference Between Interface And Abstract Class mj


    hello friends give me the difference between interface and abstract class
    and link to find java material

    Thanx

  • RELEVANCY SCORE 3.59

    DB:3.59:Abstract Class Needs To Implement Interface ms


    Hello, I have an interface and base abstract class defined as follows: interface IbusinessInterface{    void DoSth1();    void DoSth2();    void DoSth3();    void DoSth4();    void DoSth5();    ...    ...    void DoSthN();}public abstract class BaseClass : IBusinessInterface{    public abstract void DoSth1();    public abstract void DoSth2();    public abstract void DoSth3();    public abstract void DoSth4();    public abstract void DoSth5();    ...    ...    public abstract void DoSthN();} what is the reason that this abstract class needs to have methods of the interface implemented  ?Thanks, Michal

    DB:3.59:Abstract Class Needs To Implement Interface ms

    Look at the other side of the coin!  Think interface contract.  The abstract base class is NOT defining any default implementation for you.  Now, when you browse the abstract class you can SEE the member methods that are or not implemented without having to look any further.  Also, when the members of the abstract class are declared as abstract the IDE can generate method stubs for you automatically!  That does not happen if they are declared as virtual.

    Mark the best replies as answers. Fooling computers since 1971.

  • RELEVANCY SCORE 3.59

    DB:3.59:Interfaces Vs. Abstract Classes ps


    1) is there a difference between an interface (that has methods to override) and an abstract class?

    2) also what is the purpose of static members, static methods, and static classes??

    3) is there a distinction between an Abstract Data Type and User Defined Data Types?

    DB:3.59:Interfaces Vs. Abstract Classes ps

    Read Core Java Fundamentals Volume 1 by Horstmann Cornell from Sun Micro. Press release.
    Its a must to know them very well from reading it from the above book rather than relying on what you hav learnt from a discussion board. by the way, its just a personal statement, not intended to offend any fellowmates of the discussion board.

    cheers

    -tamoghna

  • RELEVANCY SCORE 3.58

    DB:3.58:When Would You Use An Abstract Class Versus Interface ? zc


    Hi guys

    When would you guys use an Abstract Class versus and Interface ?

    Stev

    DB:3.58:When Would You Use An Abstract Class Versus Interface ? zc

    Another important distinction: declaring functions abstract in a base class not only forces the programmer to implement the function, but also allows messages to be routed to the implemented version.

    Given the shape example from before, the getArea call only works because abstract tells the compiler "hey look for a function prototype that matches this in the derived class"

  • RELEVANCY SCORE 3.58

    DB:3.58:Difference Between An Interface And An Abstract Class 9f


    Hey:

    I'm curious, what's the difference between an interface and an abstract class? Thanks.

    DB:3.58:Difference Between An Interface And An Abstract Class 9f

    "You have an abstract class if you want to implement some of the methods in it, but you do not want users to make instances of the class or do not want to implement all of the methods. Take a look at some of the abstract classes in java.util. Nearly all of the methods are implemented already so that it's far easier to create new data structures than if only interfaces were provided. "

    That's what I was looking for. Thanks.

  • RELEVANCY SCORE 3.58

    DB:3.58:Compilation Error : Interface Expected Here ax


    Can interface extend abstract class?

    I tried but got the following error:

    Interface extended here

    Can anyone help plz.

    DB:3.58:Compilation Error : Interface Expected Here ax

    A class which extends the abstract class should provide the defnition for the abstract methods declared in the abstract class.

    Interface declares only a function declaration not definition of the methods.
    look at the following
    If interface extends abstract class, how will it provide defintion for the abstract methods?

  • RELEVANCY SCORE 3.57

    DB:3.57:What Is The Different Between Abstract An Interface Class? jf


    what is the different between abstract an interface class?
    and
    What is the different between access specifier of public and friendly.

    DB:3.57:What Is The Different Between Abstract An Interface Class? jf

    what is the different between abstract an interface
    class?interfaces contain only signatures of method you'll have to implement and constant
    whereas abstract classes contains method implemented and/or method non implemented

    What is the different between access specifier of
    public and friendly.the scope of 'friendly' is the package which contains it

  • RELEVANCY SCORE 3.56

    DB:3.56:Interfaces And Abstract Classes ck


    Hello,

    I am confused between an Interface and an abstract class. I would cite an example:

    I consider various shape objects esp. square, rectangle etc. and consider a common behavior area which I need to determine for each of these shapes. Should I consider an Interface or an abstract class and why?

    DB:3.56:Interfaces And Abstract Classes ck

    Hint: Interfaces say what objects must do; abstract classes say (partially) how to do them (i.e., it can provide implementations).

    Two shapes are circles and squares.

    To what extent do you think you'll reuse an area() calculation between them?

  • RELEVANCY SCORE 3.55

    DB:3.55:Concept Of Abstract Class &Amp; Interface fc


    Hi friends,

    My question is what is the main difference between Abstract class Interface?

  • RELEVANCY SCORE 3.54

    DB:3.54:Abstract Class Vs Interface sc


    can anyone pls help me in understanding difference between an interface and an abstract class which has no function with implementation

    which is better abstract cls or interface in term of speed, features..?
    Thanksbahushekh

    DB:3.54:Abstract Class Vs Interface sc

    To Mike Feng or any other moderator,
    Can you unmark
    as answer the previous post from myself please?
    Reason: It has no relevance to the original question, I was just replying to the post preceding it from RudeDog2
    which I also feel, does not really relate to the original question.
    I will leave it to Rudy to decide if He wants that post to be unmarked.

    Regards,

    John

    Click this link to see how to insert a picture into a forum post.

  • RELEVANCY SCORE 3.54

    DB:3.54:What Is The Difference Between Abstract Class And Interface af


    hi,recently i went for an interview they ask me what is abstract class ,interface and its difference
    I said abstract class contain abstact method ,abstract method is a method with no body.Abstract class cannot be instantiated.Abstract class is a base class it required derived class for the implementation of method.
    Interface is a syntactical contract that all derived class should follow
    it define properties ,method,events which are known as member of interface.
    Then They asked me what is the difference between them. I said
    abstract class interface
    1.abstact class can implement method 1.interface cant
    2.abstact class can contain constructor, 2.interface cant
    destructor
    3.abstract class cannot support multiple 3.interface support
    inheritance
    etc
    Then they said some different answer I said dont no.
    Then they ask me when i should make abstract class for an project and when
    i should make interface.
    I said if suppose there is two class which must be having method with different logic then we sholud make abstract class.
    and if suppose we have two class having method .with different logic then we can make interface .
    Am i correct with my explaination.if not correct me .please provide me that when should we create abstract class and interface and what is difference .please help me

    DB:3.54:What Is The Difference Between Abstract Class And Interface af

    I would focus the answer on the distinction that you cant add an abstract class to an existing class like you can an interface.

  • RELEVANCY SCORE 3.51

    DB:3.51:Interface Vs Abstract Class 81


    hello
    what to use when between interface vs abstract class?
    and which one is better for decoupling and different version on software.
    regardsIt's Me

    DB:3.51:Interface Vs Abstract Class 81

    For a detailed discussion on this see:
    Abstract Class vs InterfaceJohn Grove - DSS, Senior Software Engineer

  • RELEVANCY SCORE 3.50

    DB:3.50:Who Can Tell The Difference Of The Abstract Interface Class? xf


    someone ask me that he had a abstarct interface class, such as :
    public abstract interface Book{
    }
    I was comfused, who can tell me why use it?

    DB:3.50:Who Can Tell The Difference Of The Abstract Interface Class? xf

    Cross post - http://forum.java.sun.com/thread.jspa?threadID=694601tstart=0

  • RELEVANCY SCORE 3.49

    DB:3.49:Can Interface Extend Abstract Class? k3


    Can interface extend abstract class?

    I tried to make a interface extend an abstract class but i got an error stating:
    interface expected here.

    Can anyone help me ?

    DB:3.49:Can Interface Extend Abstract Class? k3

    ok, but can an interface implement an abstract class?

    No. An interface provides no implementation whatsoever. An abstract class can implement an interface, but not the other way around.

    http://java.sun.com/docs/books/tutorial/java/concepts/interface.html

    ~

  • RELEVANCY SCORE 3.49

    DB:3.49:What Is The Difference Between An Abstract And An Interface Class? pk


    can anyone enlighten me on this, what is the difference between an interface and an abstract class? When should i use an interface instead of a class and vice-versa? thanks!

    DB:3.49:What Is The Difference Between An Abstract And An Interface Class? pk

    public class Test extends MyClass implements MyInterface {
    public Test() {
    someAbstractMethod();
    someInterface();
    someMethodInAbstractClass();
    super.someMethodInAbstractClass();
    }
    public static void main(String[] args) {
    Test foo = new Test();
    }
    public void someAbstractMethod() {
    System.out.println("someAbstractMethod() in Test");
    }
    public void someInterface() {
    System.out.println("someInterFace() in Test");
    }
    // public void someMethodInAbstractClass() {
    // System.out.println("someMethodInAbstractClass() in Test");
    // }
    }

    abstract class MyClass {
    public void someMethodInAbstractClass() {
    System.out.println("someMethodInAbstractClass() in MyClass");
    }
    public abstract void someAbstractMethod();
    }
    interface MyInterface {
    public void someInterface();
    }Run once, uncomment code, run again, compare output

  • RELEVANCY SCORE 3.47

    DB:3.47:Abstract And Interface fa


    Dear Sir/Madam,

    Please let me know the difference between Abstract class and Interface.

    DB:3.47:Abstract And Interface fa

    I disappeared as i was checking the forums in javaworld.com, but now i will keep this site as main.

  • RELEVANCY SCORE 3.47

    DB:3.47:Difference B/W Abstract Class And Interface dx


    hi friends,

    can anyone plz divulge the differences between abstract class and interface and under what situations can we use these concepts.

    thanks

    madhusudan.D

  • RELEVANCY SCORE 3.47

    DB:3.47:Abstact Class Or Interface d3


    why would one use an abstract class versus an interface?

    DB:3.47:Abstact Class Or Interface d3

    MachBork wrote:
    why would one use an abstract class versus an interface?Don't you think think that this has been asked here in this forum, oh say a gazillion times? Please learn to search the forum for all the many threads on this and other questions.

  • RELEVANCY SCORE 3.47

    DB:3.47:Re: Difference Between Abstract Class And Interface. f3


    Thanks, jverd. I have got it.

    George

  • RELEVANCY SCORE 3.46

    DB:3.46:Abstract Class &Amp; Interface 17


    What is the difference between Abstract Class and Interface Class? What I understood is both has to be defined in the subclass i.e methods. Apart from that Interface supports multiple inheritance whereas Abstract class doesn't. When both has to be defined in the subclass and interface supports multiple inheritance why we still need Abstract Class.

    Thanks in Advance,
    R.Ravindhran

    DB:3.46:Abstract Class &Amp; Interface 17

    A class can only extend one other class (Abstract or not) but it can implement any number of interfaces.

  • RELEVANCY SCORE 3.46

    DB:3.46:Abstract Class And Interface 7x


    Hi,
    This is ramana, I got a doubt
    1. I have one interface
    interface Intabs {
    abstract void method1();
    abstract void method2();
    abstract void method();

    }
    2. Iam trying to convert that interface into abstract class like below
    interface Intabs {
    abstract void method1();
    abstract void method2();
    abstract void method();

    }
    3. Again iam trying to extend that abstract class into class like below
    interface Intabs {
    abstract void method1();
    abstract void method2();
    abstract void method();

    }

    Iam getting errors

    Can i do it in multiple steps: Interface------abstract class----- class

    DB:3.46:Abstract Class And Interface 7x

    Cannot reduce the visibility of the inherited method
    from IntabsDerabst1.java
    Right. As mentioned, you can't assign weaker access priveleges to inherited methods. If you define a method as "public void foo() {}", the "foo()" method must have at least public access in all subtypes. In your example, your interface methods are public, but you're trying to give them "package-private" (default) access in the abstract and concrete implementation classes.

    ~

  • RELEVANCY SCORE 3.45

    DB:3.45:Difference B/W Abstract &Amp; Interface dx


    Anyone tell me 4 difference b/w abstract class and interface
    plz help me

    DB:3.45:Difference B/W Abstract &Amp; Interface dx

    Asking once is enough.
    http://forum.java.sun.com/thread.jspa?threadID=734361

  • RELEVANCY SCORE 3.45

    DB:3.45:Best Situation That Describe Difference Between Interface And Abstract c7


    Hi, Please tell me the best example or situation where we should choose interface or abstract class?

    DB:3.45:Best Situation That Describe Difference Between Interface And Abstract c7

    Smiley,
    It is the same as about apples and computers.
    An Interface is a contract, it describes what a class should contain to implement it (and can than be used to to get those members of a class whichfulfillthe contract) but an interface contains no actual implementation.
    An Abstract Class is a class itself which can be (only) inherited used as base for another class, the members and properties of a base class can be used likewise the inheriting class.
    Because of above can an Abstract Class implement an Interface, however an Interface cannot implement an Abstract class.

    Success
    Cor

  • RELEVANCY SCORE 3.45

    DB:3.45:Re: Abstract Class Vs Interface Difference jc


    While this is by no means complete, the major
    differences between an interface and an abstract
    class with all abstract methods is that you don't
    have to create an implementation for the abstract
    methods in a class that extends the abstract class.Yes you do; unless the extending class is also abstract.

    You do have to implement all methods in an
    n interface. Also you can use access modifiers other
    than public in an abstract class, while interface
    methods must always be public. public or package-private?

    If you don't know why either of these things would be useful then you
    probably don't care, and could just use an interface.And seeings as people are answering here desipte the laziness; abstract classes can also have implemented methods, and member variables. Interfaces cannot.

    DB:3.45:Re: Abstract Class Vs Interface Difference jc

    While this is by no means complete, the major
    differences between an interface and an abstract
    class with all abstract methods is that you don't
    have to create an implementation for the abstract
    methods in a class that extends the abstract class.
    You do have to implement all methods in an
    n interface. No.

    The rules for what must be implemented are the same regardless of whether it's a class or an interface.

  • RELEVANCY SCORE 3.45

    DB:3.45:Abstract Class And Interface 97


    is it any differences between abstract class and interface?

    DB:3.45:Abstract Class And Interface 97

    And of course you [url http://onesearch.sun.com/search/developers/index.jsp?col=devforumsqp_name=Java+Programmingqp=forum%3A31qt=%22+differences+between+abstract+class+and+interface%22] searched first....

    Mike

  • RELEVANCY SCORE 3.45

    DB:3.45:Diffrence Between A Interface And A Abstract Class? f7



    Hi OO ABAP Gurus

    Please clear below point to me.

    Diffrence between a Interface and a abstract class?

    Many thanks

    Sandeep Sharma..

    DB:3.45:Diffrence Between A Interface And A Abstract Class? f7


    Interface:

    All the methods of the class ARE UNDEFINED. You need to implement the interface in a class and give the method definition now. In other words INTERFACES just have the declarations no definitions.

    Abstract Class:

    All the methods which are defined for the class may have the definition or may not. Say we have 3 methods defined for this particular abstract class but only 2 have the definition and 1 does not have the definition. Then it becomes the abstract class.

    So, every Interface is a abstract class but not every abstract class is interface.

  • RELEVANCY SCORE 3.45

    DB:3.45:Abstract Class Or Inteface 89


    Pls give me some practical example of choosing among abstract class and interface.

    DB:3.45:Abstract Class Or Inteface 89

    Search these forums using the box on the left. This question is asked about 50 times a week, there are tons of answers around

  • RELEVANCY SCORE 3.43

    DB:3.43:Re: Abstract Class-Interface kk


    why abstract class is faster than interface?

    Because mauve has the most RAM.

    ~

    DB:3.43:Re: Abstract Class-Interface kk

    Do you know any documentation about this of Sun's current JVM?No, sorry. If there are docs about this, [http://research.sun.com/techrep/] is probably a start. I believe that the Self Project [http://research.sun.com/self/] was also pretty influential and has some papers available.

    If you need a definite answer on how it is implemented in the current JVM and are fluent in C, you could take a look at HotSpot's source code. I browsed a bit (out of curiosity) and admittedly it's, well, complex (surprise! ;-) -- but given some time (and interest, of course) I guess one should be able to at least get an idea of how it works (fortunately there are some comments, too). I used OpenGrok here [http://opengrok.neojava.org/hotspot], and found some entry points for further investigation; maybe they're helpful:

    [http://12.101.252.19/hotspot/xref/src/share/vm/interpreter/cInterpretMethod.hpp], search for "CASE(_invokeinterface)"
    [http://12.101.252.19/hotspot/xref/src/share/vm/runtime/javaCalls.cpp#call_virtual]
    [http://12.101.252.19/hotspot/xref/src/share/vm/opto/doCall.cpp#do_call]

    [http://12.101.252.19/hotspot/xref/src/share/vm/oops/klassVtable.hpp]
    [http://12.101.252.19/hotspot/xref/src/share/vm/oops/klassVtable.cpp], "miranda methods"

    [http://12.101.252.19/hotspot/xref/src/share/vm/interpreter/linkResolver.cpp] (?)

    Or just try your luck in the HotSpot Internals forum...

  • RELEVANCY SCORE 3.43

    DB:3.43:Help With Interface And Abstract cs


    Hi all

    what is the difference between an interface and an abstract class??

  • RELEVANCY SCORE 3.43

    DB:3.43:What's The Difference Between Abstract Class And Interface? 1z


    Dear all,
    Can anyone give me some hints about this topic?

    Thanks.

    Leo

    DB:3.43:What's The Difference Between Abstract Class And Interface? 1z

    Also, you can only extend one class, but can implement many interfaces. I extend a class for true is-a relationships, I use implements like mixins.

  • RELEVANCY SCORE 3.43

    DB:3.43:Difference % Abstract Class And Interface? d3


    Hi,

    I am confused about abstract class and interface. For interface, the subclass has to implement all the parent class methods. But, it is no need in abstract class.

    However, in which situation should I use abstract class or interface?

    Thanks for explanation.

  • RELEVANCY SCORE 3.43

    DB:3.43:Make Abstract Class With Interface. 39


    I want to make an abstract class with methods that need interfacing, but I don't want to make an entire other class for the abstract class to implement. Is there any way to make an abstract class and interface combined into one class with no implementations on that class?

    DB:3.43:Make Abstract Class With Interface. 39

    if you want a class with no implementations that what you need is an Interface

  • RELEVANCY SCORE 3.42

    DB:3.42:Difference Between Abstact Class And Interface fk


    hi

    i am new in java.

    plz tell me abstract class support which type of polymorphisam and
    interface support which type of polymorphisam
    plz explain

    bye
    siva

    DB:3.42:Difference Between Abstact Class And Interface fk

    There's only one type of polymorphism.

    Does that make it mono-polymorphism? ;)

    Indeed - do a search for the forums.

    The short answer is that both abstract classes and interfaces define required method signatures for subclasses that extend/implement them, but abstract classes can have implementation for some or all methods that are not abstract; interfaces have no implementation whatsoever for any methods.

    %

  • RELEVANCY SCORE 3.39

    DB:3.39:Use Of Abstract And Interface? k3


    when i use Abstract class or Interface.Which one is better?

    DB:3.39:Use Of Abstract And Interface? k3

    Depends on what you want to do. An interface is more general (in that it doesn't define any actual behavior) and allows you to mimic multiple inheritance (a class can implement any number of interfaces whereas it can only extend one class (abstract or otherwise)). Abstract is good if you have a common base of functionality that all of the implementers will be using.

    It's also fairly common to use both (i.e. the interface TableModel and the abstract class AbstractTableModel), so that someone who wants to completely write their own implementation is free to, while someone who wants to just extend or change the standard functionality could do that as well.

  • RELEVANCY SCORE 3.39

    DB:3.39:Interface Vs Abstract Class sz


    Let say that an abstract class has all abstract functions and someone use it instead of interface.
    What are the disadvantage and advantages?
    I know one that he cannot do multiple inheritance, hence he cannot extends abstract class and use any other parent Class. However, I wish to know more disadvantage/advantages.

    Looking forward for your input.

    --
    PS: I know interface cannot have code and abstract class could have code (non-abstract) methods.

    .

    DB:3.39:Interface Vs Abstract Class sz

    HowToDoIt wrote:
    Let say that an abstract class has all abstract functions and someone use it instead of interface.
    What are the disadvantage and advantages?
    I know one that he cannot do multiple inheritance, hence he cannot extends abstract class and use any other parent Class. However, I wish to know more disadvantage/advantages.

    Looking forward for your input.

    --
    PS: I know interface cannot have code and abstract class could have code (non-abstract) methods.

    .An Interface expresses a contract.
    A class implementing an interface is saying "I will supply implementations of all methods described in the interface, i.e. methods with those particular signatures"

    A class can of course implement multiple interfaces, i.e. it is capable of fulfilling multiple contracts.

    An Abstract class is used to provide a 'base' implementation of some specific functionality (whether it is described in an Interface or not).

    I cannot think of a useful purpose for an abstract class that contains only abstract methods (perhaps it inherits some behavior from its base class)

    Usually some methods in an abstract class WILL be implemented, either because they are unlikely to change in child classes, or they provide a guide/example of implementation, or the implemented methods may be defined in terms of some of the abstract methods, this allows classes which extend the abstract class to 'mix in' their behavior with that of the base abstract class.

    So Interface and Abstract Class have two distinct and separate purposes.

    I hope that is clear?

    Just to help with the details, you can put more than just method signatures in an interface, your could for example have in your interface

    public interface Face1
    {
    public static final int x = 3;
    }which you would access as:

    int fred = Face1.x;And you can place a public static class inside of your interface, the methods of which you would access in a similar way, but you should avoid this unless you really know what you are doing.

  • RELEVANCY SCORE 3.39

    DB:3.39:Abstract Class Or Interface. Which One Is Better 77


    hai everybody,

    i have a confusion between choosing of abstract class or Interface.

    abstract class Abstra
    {
    public abstract void abst();
    }
    interface Inter
    {
    public abstract void inter();
    }

    looks almost same !!!
    which one of above is better to inherit for a class.
    and more importantly why ?
    Everybody says it's interface....but i dont understand what could be the reason.
    i want to know the reason if interface is better as compare to abstract class.
    why ? why ? why ? why ?

    DB:3.39:Abstract Class Or Interface. Which One Is Better 77

    a very good answer...get to know first of all whats the difference between Abstract class and Interface.

  • RELEVANCY SCORE 3.39

    DB:3.39:Interface Abstract Class jc


    Hello,

    DB:3.39:Interface Abstract Class jc

    The example sited, as many, could be done with an abstract Account class, or with an Account interface. Given only the information in what you copied, An interface is resonable.

  • RELEVANCY SCORE 3.39

    DB:3.39:Interface And Abstract Class ac


    hi all,

    A method in an interface consists of access specifiers as public or abstract. what is the difference if the access specifiers for the method is public and abstract.

    regards,
    priya

    DB:3.39:Interface And Abstract Class ac

    That is correct. They must be because interface methods must be overridden when subclassed.

  • RELEVANCY SCORE 3.38

    DB:3.38:Concrete Class ff


    Hi

    Could someone tell me what the difference is between an abstract class, interface class and a concerte class. Cant figure it out.

    Thank you
    David

  • RELEVANCY SCORE 3.37

    DB:3.37:Difference Between Abstract Classes Vs Interface 77


    Hi,
    Can u pls mention all the differences between Abstract Classes and Interface.? I've mentioned the differences I've known here.

    Known Differences:
    ------------------
    (*) An interface cannot implement any methods, whereas an abstract class can.
    (*) A class can implement many interfaces but can have only one superclass

    Can U pls mention at what situation(practical situation) we've to go for abstract class or Interface?
    Tell me the situation when we have to go for abstract class?
    Tell me the situation when we have to go for interface?

    Please Reply me
    Thanks Regards
    Venkatesh

  • RELEVANCY SCORE 3.37

    DB:3.37:Confusion Between Abstract And Interface a8


    Hi all,
    i'm new to java, can somebody help to explain on abstract and interface method. As i know that abstract or interface does not provide implementation in the superclass and interface class respectively. All the implementation are done in subclass.. why not we use the inheritances and abstract method to solve the problem instead of using the interface... i can't see the difference between the abstract and interface.. can somebody provide me a good example to understand the interface well..

    p/s: pls correct me if i wrong... ;)
    thanks

    DB:3.37:Confusion Between Abstract And Interface a8


    public class abstract Mainclass{
    abstract double area();
    abstract double meter();
    }

    public class Subclass1 extends Mainclass{
    double area(){
    return 5+1;
    }
    }

    public class Subclass2 extends Mainclass{
    double area(){
    return 8+10;
    }
    }Let's say you have
    public class abstract AreaClass {
    abstract double area();
    abstract double meter();
    }And then when you are working on your second iteration and you want to use Dimension class for this purpose for your new code but you want to leave the old code alone. If you have made AreaClass an abstract class, this is impossible.
    public class AreaDimension extends AreaClass, Dimension {
    }will not compile. However if you had defined AreaClass as and interface you can do this:
    public class AreaDimension extends Dimension implements AreaClass {
    double area() {
    return height * width;
    }
    }Then you can pass this to any method that accepts an AreaClass as a parameter and you can also pass it to any method that takes a Dimension.

  • RELEVANCY SCORE 3.33

    DB:3.33:Difference Between Abstract Class And Interface j3


    What is the difference between anabstract class and aninterface ?

    DB:3.33:Difference Between Abstract Class And Interface j3

    Hi,
    Check this link differencebetween an abstract class and an interfacePS.Shakeer Hussain

  • RELEVANCY SCORE 3.33

    DB:3.33:Diff. Between Interface And Abstract Class 3s


    hi,
    Can any one tell me about diff between interface and abstract class in practical way.advanced thanks for ur response.
    -PVMVS

    DB:3.33:Diff. Between Interface And Abstract Class 3s

    This question gets asked all the time. I found lots of hits by searching this forum with the words: interface abstract class difference

    I'm sure google will return even more. Searching existing posts should always be done before posting.

  • RELEVANCY SCORE 3.32

    DB:3.32:Interface Vs Abstract Class d8


    when do we need interface and when abstract class?

    DB:3.32:Interface Vs Abstract Class d8

    2.All the abstract methods must be overrided and
    implemented by the child class.by definition, you can't override a method that has no implementation

    3.Real Examples:

    when we implement the ActionListener interface for
    Button click event then we have to override the
    actionPerformed method, we dont have any other
    chices, so it is a way of forcing the inherited class
    to override certain methods.as before, we implement an abstract method. you're not forcing an override, this can't be done, nor would it be a good idea. as discussed at length recently :-)

    n java you can see all the classes that starts with
    Abstract is abstract.not so. there's nothing at all to stop you writing a concrete class named AbstractClass

  • RELEVANCY SCORE 3.31

    DB:3.31:Abstract Class And Interface Having Same Method fa


    Hello,

    Here is my problem. Suppose we have one abstarct class and one interface.Here is code-
    //Abstarct class
    abstract class X{
    abstract void myMethod();
    }

    //Interface
    public interface Y{
    abstract void myMethod(){}
    }

    Now i have a class which extends both abstarct class X and interface Y.
    If i call myMethod() from this class. Whose myMethod would be called.Will it be of abstract class or interface?
    Many Thanks

    DB:3.31:Abstract Class And Interface Having Same Method fa

    Oops, last part should be

    Now, let's pretend the abstract class above did have code in it.
    //Abstract class
    abstract class X {
    void myMethod() { System.out.println("Hello"); }
    }
    Then, you wouldn't have to have a myMethod() implementation in your class which extends X and implements Y (it's defined in X). If you didn't have one, the method in X would run. If you defined your own myMethod() implementation in your class (which extends X and implements Y), then your own implementation would run.

  • RELEVANCY SCORE 3.31

    DB:3.31:Abstract Class Vs Interface And Importance Of Using xm



    Hi All,

    I want to know what is the difference between Abstract class and Interface.

    and what is the importance of using them.

    Moderator message: please search for available information/documentation.

    Edited by: Thomas Zloch on Sep 27, 2011 1:55 PM

    DB:3.31:Abstract Class Vs Interface And Importance Of Using xm


    Please refer to this thread, already this is discussed in forums

    [ABAP Objects.. Abastract Interface Class;

    Thanks

    Pavan

  • RELEVANCY SCORE 3.30

    DB:3.30:Complete Differences 1d


    Hi,
    Please provide me all possible differences between...

    1). Prepared Statement and Callable Statement
    2). Abstract Class and Interface

    Thanks,
    R S

    DB:3.30:Complete Differences 1d

    See this

    http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html

  • RELEVANCY SCORE 3.30

    DB:3.30:Difference Between A Abstract Class With 4 Abstract Methods And A Interface With 4 Abstract Methods. 8c


    what is the difference between Difference between a Abstract class with 4 abstract methods and a Interface with 4 abstract methods.

    DB:3.30:Difference Between A Abstract Class With 4 Abstract Methods And A Interface With 4 Abstract Methods. 8c

    Your question is better rephrased as: What is the difference between an abstract class and a interfase?
    This has been discused here
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/67451957-f0bd-4b9b-a2c0-16f604ce8643
    Regards

  • RELEVANCY SCORE 3.28

    DB:3.28:Abstract Class And Interface mc


    From the design perspective what is the difference between Abstract class and Interface.
    If we are providing design, for a system. When should we use abstract class? and when should we use interface.

    DB:3.28:Abstract Class And Interface mc

    And,
    you can only "extends" one abstract class;
    but "implements" several interfaces.

  • RELEVANCY SCORE 3.28

    DB:3.28:Abstract Classes And Interfaces kp


    I am kinda new to Java but have been studying frequently. I have a question that is probably very simple: What is the difference/advantage between an abstract Class and an Interface?

    DB:3.28:Abstract Classes And Interfaces kp

    Search the forum. Here's a topic that addresses it:
    http://forum.java.sun.com/thread.jsp?forum=31thread=273324

  • RELEVANCY SCORE 3.28

    DB:3.28:Abstract Interface ss


    Hi All,
    What is abstract interface?What is the difference between Abstract interface and interface?
    If there is no difference why ServletRequest is abstract inteface.
    Thank You,
    Selvaraj

    DB:3.28:Abstract Interface ss

    Have a look at the JLS Chapter 9.1.1.1 abstract Interfaces
    Every interface is implicitly abstract. This modifier is obsolete and should not be used in new programs

  • RELEVANCY SCORE 3.28

    DB:3.28:Difference B/W Abstract Class And Interface mf


    Hi,
    can anyone tell the difference between Abstract class and an Interface?

    Thanks in advance!

    DB:3.28:Difference B/W Abstract Class And Interface mf

    The majoor diiffernce is that Interface canot ber
    inherited while absract calss can be inherited
    one abract class can iheret other abstract class
    while Interface doesnot???

  • RELEVANCY SCORE 3.28

    DB:3.28:Interface And Abstract Class c8


    Hi,

    Could you please let me know what is the exact difference between interface and abstract class.Which one is better to use .Could you please give me indepth answer.

    DB:3.28:Interface And Abstract Class c8

    Stop. Stop. Stop. I beg you...You're behaving like a Chinese gentleman with sand in his boots. Stop.

    Do we save the execution time by using interface.This is a compiler/byte code related question. Please post it in the proper place.

    What might be the behaviour inside the memory
    location by using interface and abstract class.Same answer.

    /Morten

  • RELEVANCY SCORE 3.27

    DB:3.27:Abstract Class And Interface???? ja


    hi all, i would like to know the difference between abstract class and interface....could anybody enlighten me on this....

    DB:3.27:Abstract Class And Interface???? ja

    search the forums, lot's of times answered this one has been.

  • RELEVANCY SCORE 3.27

    DB:3.27:Interface And Abstract Class c3


    why we have constructor for abstract class and not for interface,

    DB:3.27:Interface And Abstract Class c3

    http://forum.java.sun.com/thread.jspa?messageID=10174604

    Double your pleasure or not!