• RELEVANCY SCORE 5.81

    DB:5.81:Abstract Classes And Interfaces? dp




    Can someone tell me whats the difference between abstract classes and interfaces?

    DB:5.81:Abstract Classes And Interfaces? dp

    ...alhough an abstract class doesn't have to have any abstract methods, or any methods at all for that matter. If it has an abstract method (or doesn't implement something from an interface it claims to implement) then it must be declared abstract, but the reverse is not true--any class may be declared abstract.

  • RELEVANCY SCORE 5.35

    DB:5.35:Re: Interface m8




    Java Glossary : interface vs abstract class
    Abstract classes vs. interfaces: When does it make sense to choose an abstract class over an interface?
    Abstract classes and interfaces practicum: Move from theory to practice on when to employ abstract classes vs. interfaces
    Tech Tips: ABSTRACT CLASSES VS. INTERFACES

    DB:5.35:Re: Interface m8

    I'm still entertained by the fact that some folks will
    spell out words like "multiple", "inheritance",
    "interface", and "implement", but not "because".

    :o)LOL!

    This kills me - just bcuz.

    %

  • RELEVANCY SCORE 5.18

    DB:5.18:Interfaces And Abstract Classes k8




    Hello friends, I have shifted from C++ to C# recently. My questions are1 What is the advantage of using interface over abstract classes?2 What is the advantage of implementing built in interfaces instead of designing our own interfaces akin to the built in interfaces?

    DB:5.18:Interfaces And Abstract Classes k8

    @ all .. thanQ very much :D
     
    eacousineau... ur code makes me hungry :D ... anyway... it's a nice example ...

  • RELEVANCY SCORE 5.17

    DB:5.17:Abstract Class Vs Interface 9a


    Can somebody please explain to me why we need both abstract classes and interfaces? Don't they serve almost exactly the same role? Besides syntax and the possibility of implementing multiple interfaces, is the only difference that an abstract class is allowed to have non-abstract methods?

    DB:5.17:Abstract Class Vs Interface 9a

    interfaces also may have variables but they have to be declared final. ???

  • RELEVANCY SCORE 4.99

    DB:4.99:Difference Between Abstract Class And Interfaces 9a


    Hi,

    Any body can tell me In which scenarios we use abstract class and in which scenario we use interfaces.

    In real time applications.

    DB:4.99:Difference Between Abstract Class And Interfaces 9a

    [url http://www.javaworld.com/javaworld/jw-09-2001/jw-0921-interface.html] maximizing flexibility

  • RELEVANCY SCORE 4.87

    DB:4.87:Basic Java Mcq! d7


    I came accros a scjp quesion that is

    Which of the following are legal declerations for non nested classes and interfaces?
    A) final abstract class Test{}
    B) public static interface Test{}
    C) final public class Test{}
    D) protected abstract class Test{}
    E) protected interface Test{}
    F) abstract public class Test{}

    I think B,C,D,E,F are correct.I know that first one is wrong because final and abstract can not be used at the same time.Am i right or wrong?Can any one give me a explanation if i am wrong.

    DB:4.87:Basic Java Mcq! d7

    Also, a good site to see...

    http://www.uni-bonn.de/~manfear/javamodifiers.php

    Regards,
    Sidath.

  • RELEVANCY SCORE 4.69

    DB:4.69:Nested Interfaces And Abstract Methods zx



    Consider the following design:

    interface ZIF_INTERFACE_A.
    methods METHOD_A.
    endinterface.

    interface ZIF_INTERFACE_B.
    interfaces ZIF_INTERFACE_A.
    methods METHOD_B.
    endinterface.

    class CLASS_A_B definition abstract.
    public section.
    interfaces ZIF_INTERFACE_B
    abstract methods METHOD_B.
    interfaces ZIF_INTERFACE_A
    abstract methods METHOD_A.
    methods METHOD_C.
    endclass.
    class CLASS_A_B implementation.
    method METHOD_C.
    endmethod.
    endclass.

    DB:4.69:Nested Interfaces And Abstract Methods zx


    No, you don't have to manually do this while defining a similar global class. The class builder automatically maintains the order of the definition!

    Actually, I did have to do that. The class builder declared the interfaces in the wrong order.

    I only wrote the local classes to demonstrate the problem on this forum.

  • RELEVANCY SCORE 4.69

    DB:4.69: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:4.69: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 4.68

    DB:4.68:Recommendations For Abstract Class Vs Interfaces 71


    Hi,

    From the following URL i got some doubts about the Recommendations for using Abstract class vs interfaces

    http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx

    1. If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change.
    Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.
    { Is there any example for this t ounderstand throughly ?}

    Can any one explain with example please 2. If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.

    If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.
    { Is there any example for this t ounderstand throughly ?}

    Can any one explain with example please

    DB:4.68:Recommendations For Abstract Class Vs Interfaces 71

    Hello,
    I have stated this many times before, it's merely a rule of thumb you can follow.
    An abstract class provides common interface for
    related classes whereas an interface provides common
    functionality for classes that are not related .
    An interface is purely abstract, it is used in many frameworks and libraries to adhere to certain specification.
    Interfaces should be small as concise as possible whereas abstract classes tend to be more robust and scalable.

    Eyal, Regards.

    Any fool can write code that a computer can understand. Good programmers write code that humans can understand. -- Martin Fowler.

    Visual Studio Command Browser 2.0
    CodeVolume.Presenters

  • RELEVANCY SCORE 4.67

    DB:4.67:Difference Between Abstract Classes And Interfaces And When To Use Each a1


    Hi,
    I want to know the exact implementation differences between an abstract classes and Interfaces.
    When would we use each of them..
    Its seems that each does the same kind of functionality...but we need to just extend an abstract class in one and implement an Interface in another.

    Do let me know.

    Thanks,
    Ravi

    DB:4.67:Difference Between Abstract Classes And Interfaces And When To Use Each a1

    Hi,
    I want to know the exact implementation differences
    between an abstract classes and Interfaces.
    When would we use each of them..
    Its seems that each does the same kind of
    functionality...but we need to just extend an abstract
    class in one and implement an Interface in another.

    Do let me know.

    Thanks,
    RaviHi Ravi,
    A class must be declared abstract if one or more of its method is abstract. In case of an Interface, ALL the methods MUST be abstract. As java does not support multiple inheritence, Interface comes handy. In java, a class cannot extend from more than one class. To incorporate multiple inheritance, one can extend a class from another class and implement interface.

    public TestClass extends AbsClass implements Inter {
    }

    Thanks,
    Hope this helps,
    Karthick

  • RELEVANCY SCORE 4.51

    DB:4.51: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:4.51: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 4.50

    DB:4.50:Abstract Or Abstract-Like Classes In Winrt Components p8


    I'm building a Metro-style Windows 8 app in C# and found myself with a number of reusable components. So I decided to factor them out. Now, I'm also planning on writing some apps in other languages (C, JS, etc.) that could benefit from these components,
    so I decided to build them as WinRT components.
    My components have abstract classes to allow for some degree of extension, so of course the first thing I encounter is that abstract classes aren't allowed in C# WinRT components. This leaves me with two questions:
    1. Why?? I realize there may be issues I don't quite understand, but it seems that there exists some combination of WinRT elements that projects into C# as an abstract class (since we have DependencyObject, etc. in WinRT) but why can't I project abstract
    classes back out? I realize that interfaces are there and work, but I don't like the idea of duplicating work and maintaining a separate interface.
    2. Is there some combination of Interfaces, Sealed Classes and Attributes that can make my WinRT component _look_ like it has Abstract classes? I scanned through the IL of some of the metadata in Windows.md and it looks like those are in fact interfaces
    with matching classes, can I manually write a structure like that to get classes that look like abstract classes in C#?
    Abstract classes are essential to the utility of my components, so I'll be sticking with a .NET Class Library if there's no way to handle this. I wanted to try the other development environments out and build concrete apps in them, but without these common
    components I don't think I'll bother...
    Thanks,
    Andrew

    DB:4.50:Abstract Or Abstract-Like Classes In Winrt Components p8

    Andrew - please post your questions to internal resources. Email me directly if you have any questions. MSMALLMatt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

  • RELEVANCY SCORE 4.50

    DB:4.50:Re: Abstract Class And Interface 81


    You should never, ever, ever, ever use abstract classes. NEVER!

    You should always program to interfaces.

    So sayeth the uj.

    Like OMG, HTH, TTYL.

    DB:4.50:Re: Abstract Class And Interface 81

    georgemc wrote:
    filestream wrote:
    You should never, ever, ever, ever use abstract classes. NEVER!

    You should always program to interfaces.

    So sayeth the uj.

    Like OMG, HTH, TTYL.Apart from when I say that, in which case she seems obliged to take the opposite stance. Seriously, recently she was both arguing for and against preferring composition over inheritance in two threads simultaneously, simply in order to gainsay my points. Quite bizarre behaviour, albeit quite revealingRight. That's what I was referring to.

  • RELEVANCY SCORE 4.41

    DB:4.41:Practial Use Of Abstract Classes And Interfaces dx


    Hi! I'm a bit new to Java and right now I'm reading about abstract classes and interfaces.

    Can you tell me a practical (and real world) situation where I can take advantage of this?

    I've reading that interfaces just declare methods with their signatures, and abstract classes declare the methods and the class who extends it do the right thing with it. But it is not the same thing to just write the method in the class who uses it, instead of doing abstract or interfaces?

    Please "bring light" to this issue :)

    Regards

    DB:4.41:Practial Use Of Abstract Classes And Interfaces dx

    Many thanks to all of you who posted your comments, all of your comments were of a lot, lot of help, and help me to clarify these concepts.

    Best Regards!
    Raul

  • RELEVANCY SCORE 4.41

    DB:4.41:Readonlystringproperty Vs Stringexpression kd


    Where is the difference between them?

    From the JavaDoc it seems ReadOnlyStringProperty overrides equals, hashcode and toString. But I see no difference when using toString. Where is the reals benefit to each of them?

    Another thing: Why are there so many interfaces and abstract classes in javafx.beans.*? This is confusing.
    I mean:

    ReadOnlyProperty
    StringExpression
    ObservableObjectValuejava.lang.String
    ObservableStringValue
    ObservableValuejava.lang.String

    ===

    ObservableObjectValuejava.lang.String and ObservableStringValue are basically the same and only add one method (get()) to ObservableValue.

    Why so many interfaces?

    DB:4.41:Readonlystringproperty Vs Stringexpression kd

    Sorry for not being clear. It is always confusing which site is meant when talking about bindings.

    If you have a read only property p, you can bind another property to it (a.bind(p) works), but you cannot bind the read only property to something else (p.bind(a) does not work).

  • RELEVANCY SCORE 4.38

    DB:4.38:Is There A Worth Of A Pain To Create Interfaces Over An Abstract Class? pf


    hi friends,
    An Abstract class contains declaration of members and must inherit class in order use it, an interface is also contains declaration of member and must implement and override members touse it. So there is no visible difference between them. But while
    i was at a class my tutor pointed out that it would be better to create interfaces than classes becuase MS kneen on interfaces (UNOFFICALLY). Well, since interfaces seems bit odd in my opinion i would give priority to creating abstract classes than interfaces.
    So am i correct in there, is there worth of pain to create interfaces over abstract classes?
    thanks

    DB:4.38:Is There A Worth Of A Pain To Create Interfaces Over An Abstract Class? pf

    Splitting a design up into Interfaces Implementations is the way to go I think, and if you look at any MS SDK (or even COM as a whole) you will see this is pretty much the official MS stance on it.
    See also the Bridge Pattern.SDET, Lync SDK Team

  • RELEVANCY SCORE 4.38

    DB:4.38: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:4.38: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 4.35

    DB:4.35:Why Are Properties Provided In Interface? sc


    Hello,
    1. I would like to have clear idea about why are properties provided/allowed in interfaces?
    2. We can achieve everything from abstract class (havin no method implementation for all the methods) that we acheieve from the interfaces. Implementing multiple interfaces provides a way to have multiple inherentece. Apart from that is there any other
    reason why to choose interfaces over abstract classes?
    (I don't want typical differences between abstract class and the interfaces which are found everywhere. I'm expecting answers from the design perspective or thethought process behind having both of them that way).

    DB:4.35:Why Are Properties Provided In Interface? sc

    Hi Louis,
    Thanks a lot for descriptive answer. Excellent.

  • RELEVANCY SCORE 4.30

    DB:4.30:Jsf Annotations On Interface Or Abstract Class xa


    Hello,

    Can we use JSF 2 annotations like @ManagedBeans or @SessionScoped for interfaces and abstract classes? I mean, will it works if I implement an interface which declares some annotation(s) and the managed bean class itself doesn't have annotations?

    Thanks a lot!
    Oleg.

    DB:4.30:Jsf Annotations On Interface Or Abstract Class xa

    Okey, an example:

    @ManagedBean
    public abstract class MyAbstractClass {
    ....
    }

    public class MyClass extends MyAbstractClass {
    ....
    }

    Does it work if I access MyClass by ValueExpression #{myAbstractClass} ? Will be MyClass automatically annotated with @ManagedBean?

    Best regards.
    Oleg.

  • RELEVANCY SCORE 4.29

    DB:4.29:Re: Abstract Classes Implementing Interfaces. Why?? pf


    ok, So why cant we define a class having the all the functionality , and then extend this class
    once and for all.

    Do you get my point,please ? This way, there is no interface involved.

    DB:4.29:Re: Abstract Classes Implementing Interfaces. Why?? pf

    good rasmeet ........a careful judgement of the "abstactness".Thank You.

  • RELEVANCY SCORE 4.26

    DB:4.26:When Should I Use Abstract Classes And When Should I Use Interfaces? da


    Can any body tell me in which scenario we use /we go for Interface and which scenario we go for abstract class, because as per my knowledge what ever thing we can do by using Interface that thing can also done through abstract class i mean to say that the
    behavior of the two class.
    And other thing i also want to know that which concept comes first into the programming abstract class or Interface.

    S.K Nayak

    DB:4.26:When Should I Use Abstract Classes And When Should I Use Interfaces? da

    excellent explanation
    Although one difference between abstract classes and interfaces doesn't seem to have been explicitly stated (I think it is implied in a couple of posts). That is a class can implement several interfaces, but it can only inherit from one class (abstract or otherwise).
    So interfaces are useful for related types of behavoiur that are expected to be only subset of the behaviour of the implementing classes.

  • RELEVANCY SCORE 4.25

    DB:4.25:Re: Why Interfaces And Abstract Classes In Java pm


    I am new to this forum I'm not sure what that has to do with anything.

    thank you very much for you
    supportYou're welcome.

    DB:4.25:Re: Why Interfaces And Abstract Classes In Java pm

    I think that's about the same age I can first
    remember using computers. In elementary school they'd
    take us to the computer lab for an hour after lunch
    to play games. Oregon Trail was my favorite, but
    number munchers was pretty boss too if all the Oregon
    Trail disks were taken. I wouldn't have learned what
    factors and primes were as early as I did if it
    wasn't for that game.I can't remember the name of the first game that I played. All I can remember is that I went to the library and found a programming book that had a game in it. I had to type the game into the computer (Vic 20) and then I could play. :)

  • RELEVANCY SCORE 4.25

    DB:4.25:Exposing Multiple Abstract Classes Or Interfaces j1


    I have client applications that need to have various interfaces (or I can use abstract classes if I have to) to inherit from. The issue is that others on the development team do not want to have endpoints for each of these interfaces/abstract classes. I've tried passing them as parameters and setting them as KnownTypes for the WCF service, but neither works. Does anyone have a solution of how to expose multiple interfaces or abstract classes through one endpoint that the client and inherit from.Thanks

    DB:4.25:Exposing Multiple Abstract Classes Or Interfaces j1

    Hi Dennis,
    Thanks for such a prompt reply :).
    With your solution I will need two services exposed on two different endpoints. However, I want to expose MathService as IAdderService on a single endpoint and only some of the client'sshould be able to access the extra services provided by IMathService onthat single endpoint.
    Below is server side implementation:
    //MathService implements IMathService and IMathService implements IAdderService
    MathService mathService = new MathService();
    ServiceHost host = new ServiceHost(mathService);
    host.Open();
    Servcer side Configuration:
    configuration
    system.serviceModel
    services
    service name=IAdderService
    behaviorConfiguration=AdderServiceServiceBehavior
    endpoint address=net.pipe://localhost/AdderService
    binding=netNamedPipeBinding
    bindingConfiguration=Binding1
    contract=TestApp.IAdderService /
    endpoint address=mex
    binding=mexNamedPipeBinding
    contract=IMetadataExchange /
    host
    baseAddresses
    add baseAddress=net.pipe://localhost/AdderService/
    /baseAddresses
    /host
    /service
    /services
    bindings
    netNamedPipeBinding
    binding name=Binding1
    security mode = None
    /security
    /binding
    /netNamedPipeBinding
    /bindings

    behaviors
    serviceBehaviors
    behavior name=AdderServiceServiceBehavior
    serviceMetadata /
    serviceDebug includeExceptionDetailInFaults=True /
    /behavior
    /serviceBehaviors
    /behaviors
    /system.serviceModel
    /configuration
    Client Side imeplementation:
    IAdderService adderService = new ChannelFactoryIAdderService(AdderService).CreateChannel();
    int result = adderService.Add(10, 11);

    IMathService mathService = adderService as IMathService;
    result = mathService.Substract(100, 9);
    Client side configuration:
    configuration
    system.serviceModel
    client
    endpoint name=AdderService
    address=net.pipe://localhost/AdderService
    binding=netNamedPipeBinding
    bindingConfiguration=Binding1
    contract=TestApp.IAdderService /
    /client

    bindings
    netNamedPipeBinding
    binding name=Binding1
    maxBufferSize=65536
    maxConnections=10
    security mode = None
    /security
    /binding
    /netNamedPipeBinding
    /bindings
    /system.serviceModel
    /configuration
    Using above code and configuration I am not able to typecast IAdderService instnace to IMathService, it fails and I get null instance of IMathService at client side.
    My observationis ifserver exposes IMathService to client then client can safely typecast to IAdderService and vice versa is also possible.Howeverif server exposes IAdderService then the typecast fails.
    I hope now the requirement is very clear.Vaibhav Gawali

  • RELEVANCY SCORE 4.25

    DB:4.25:How Abstract Class Differ, When We Call Class To Be Abstract Data Type? 7f


    We say as Classes as a realization of Abstract data types, then why should we declare that to be abstract ?

    Hope, the key word Abstract in both ADT and abstract classname mean the same.!!!!

    DB:4.25:How Abstract Class Differ, When We Call Class To Be Abstract Data Type? 7f

    No, abstract is in the case of "abstract data type" a more general term, whereas in "abstract class" it is a technical term in Java.

    Are you not satisfied with the answers here?
    http://forum.java.sun.com/thread.jspa?threadID=5303930messageID=10297137#10297137

  • RELEVANCY SCORE 4.23

    DB:4.23:Abstract Classes Vs Interfaces 3x


    Why do we need Interfaces when we have Abstract Classes?Please give me a simple example and a real usage of Interfaces.
    Thanx

    DB:4.23:Abstract Classes Vs Interfaces 3x

    I don't think interfaces are trying to cover the multiple inheritance of C++. And there is no issue about abstract classes and interfaces, but inheritance and implementation. Even, they have a very different use.

    Inheritance should be used to specialize an object, instead implementation is more oriented to container issues. I mean, when you write any kind of container you don't want to be forced to use a unique kind of specialized objects, but objects that reponds at your container needs. Inheritance will improve the objects of your container, but the interface is the suitable solution to meet those container needs.

    Supose you write a Desktop that should own docked windows. Supose that you will talk to some well-known methods of this windows and you will implement them in the base class JDockedWindow, which inherits from JFrame. As long as all your needs fit into JDockedWindow this solution is good enough, but what if JFrame is not a right base class for something new you want to do?

    Supose now that you have created an interface called DockedWindow with the well-known methods used by Desktop to talk to the owned windows. Now you implement this interface in the JDockedWindow. Everything seems to be the same, but instead of adding an instance of JDockedWindow class to the Desktop you add an instance of the implemented interface DockedWindow. Just with change you become free to implement this interface to the new thing you want to do. See, inheritance helps you on improving docked windows, while implementation is letting you to add new and totally different specialized objects.

    Sorry, this is too large and my english isn't good enough. But I couldn't stop it.

  • RELEVANCY SCORE 4.20

    DB:4.20:Whats The Difference Between Abstract Classes And Interfaces? sp


    What's de advantage ov Interfaces and vice versa the advantage of the Abstract Classes?
    Thanks

    DB:4.20:Whats The Difference Between Abstract Classes And Interfaces? sp

    1. Interface only contains Skeleton methods (no implementation at all). An interface does not have member variables.

    2. Interface does not have access modifiers.
    3. However interfaces help us in achieving multiple inheritances i.e. a class cannot inherit multiple classes (also abstract class) but it can inherit multiple interfaces.

    4. Abstract class contains Skeleton methods as well as default implementation (common functionality).

    5. Abstract class contains member variables and access modifier (default is private).

    6. Use abstract class if you need to modify base class because once base class is modified, we don’t need to change sub classes. But in case of interface, once interface is created and used, we cannot change base class. In this case we may need to add new
    interface to accommodate required change.
    7. Use abstract class if you have to implement common functionality for closely related objects (default method with provide this).

    8. Use interface if you have to implement common functionality for uncommon objects or disparate objects (in sub class implementation will provide this).

  • RELEVANCY SCORE 4.20

    DB:4.20:How To Make A Relation Between Interfaces And Classes pp


    How to make a relation between interfaces and classes.
    And How to make a relation between interfaces and abstract classes.
    In  class diagram.

    DB:4.20:How To Make A Relation Between Interfaces And Classes pp

    I agree this is an important feature.Best Regards, David K Allen http://codecontracts.info Minneapolis, Minnesota, USA

  • RELEVANCY SCORE 4.18

    DB:4.18:Abstraction Vs Interfacing d7


    I'm pretty sure you guys are going to think that this must be the stupidest question....!!!

    Ok. This is it.

    I find it hard to differentiate between the concept of abstract classes and interfaces. In the end when either of them are implemented the functionality they provide is more or less the same. If that is the case why does java provide both interfaces and abstract classes when either one of them would do the job gracefully. I'm sorry if I'm mistaken I'm totally confused.

    Whoever it is that ends up clarifying my doubt......thanks in advance :)

    DB:4.18:Abstraction Vs Interfacing d7

    In an interface, all methods are abstract and public
    in an abstract class, some methods can be defined in the abstract class yet some can be blank abstract methods left to be defined by subclasses

    Interface just means EVERY method must be declared public and abstract
    Advantages to this = you can implement multiple interfaces

    You cant implement an abstract class, you can implement an interface however

  • RELEVANCY SCORE 4.17

    DB:4.17:Re: Why An Interface Is Used In A Java Program pc


    These are fair comments as per as interface is concern.... we need interface to declare the methods without implementing the methods. Basically interfaces help implementing classes in a organised way.
    Now We got abstract class also, which has got more or less same features like interfaces. In abstract class also we can declare a method without implementation.
    If we use abstract class and extend that abstract class, we don't have implement all the abstract methods in that particular class,which would extend the abstract class, but if we implement an interface in a class, we have to define all the methods with their body. Now, can anyone tell me , in a generic way, when do we use interface and when do we use abstract class. I don't need the differences between abstract class and interface...that i know...thanks in advance
    take it easy
    RD
    l

    DB:4.17:Re: Why An Interface Is Used In A Java Program pc

    For Ex: 5 years down the line, .........I always wondered why it is said "down the
    line" and not up the line.
    What's so downish about the future ?People degrade as the years pass by. :P

  • RELEVANCY SCORE 4.14

    DB:4.14:Abstract Classes And Interfaces??? xa


    Recently i have been asked a question in interview..
    '" What is the difference between abstract classes and interfaces.. I mean wut is the advantage of using one over the other"
    Can anyone please gimme a precise answer in few lines..
    Thanks much
    suresh akula

    DB:4.14:Abstract Classes And Interfaces??? xa

    You can also define "constants" (static final fields) within an interface, not just methods.

    Another noteworthy differences between interfaces and abstract classes is that within an interface, all methods and fields are implicitly public in scope. Abstract classes have no such constraint.

    Of course, there are the obvious differences: interfaces provide NO implementations, whereas abstract classes may; a class may implement multiple interfaces, but may only extend one class.

  • RELEVANCY SCORE 4.14

    DB:4.14:Interface Members In Abstract Classes? pj


    Is it common to have Abstract classes that implement interfaces or if they don't implement an interface have Interface members such as properties where the type is an Interface for that property in your abstract class? Or are Abstract Classes to
    always be seperated from Interfaces in terms of intermixing anything?C# Web Developer

    DB:4.14:Interface Members In Abstract Classes? pj

    Thanks a lot. If anyone has anything to add to Nicholas's response I'd appreciate it. I'm slowly trying to get into using more Interfaces as opposed to Abstract classes but I do see a need for both. There are some common functionality
    that subclasses need (Abstract classes with methods) while there are also common methods to a bunch of subclasses which could have slightly different implementations (Interface for those methods)C# Web Developer

  • RELEVANCY SCORE 4.14

    DB:4.14:Interfaces Vs Abstract Classes 1d


    Hi All !!!
    Can any body please tell the difference between Interfaces and Abstract Classes in terms of Third Party Convince, Homogenous and HAS-A Relation Ship.
    Regards,

    DB:4.14:Interfaces Vs Abstract Classes 1d

    do your own homework. had you just asked for the differences, you would probably have gotten an answer, but you've just dumped your homework on the forum and said "do this for me" which we won't

    search the forums for this, it's asked almost every day. but those homework questions? that's your own problem

  • RELEVANCY SCORE 4.14

    DB:4.14:I Don't Understand The Concepts Of Abstract Classes And Interfaces k7


    I have read so many articles about Abstract Classes and Interfaces, but still I cannot understand their real use. One of the reasons would be code re-use or something along those boundaries, although this doesn't make sense to me, because an interface only defines the methods, so if I were to change a method name in the Interface class, I would STILL have to re-type the method name in my classes implementing that interface right?

    I hope someone can help me with this, because my brain simply cannot process this logic, maybe I'm just not experienced enough.

    DB:4.14:I Don't Understand The Concepts Of Abstract Classes And Interfaces k7

    836981 wrote:
    These are some great comments, I'm gonna read them again tomorrow when my brain isn't spinning! Cannot currently process all the information ;)Just to add to what jverd said, abstract classes are generally most useful when used with an interface (eg, his example of List and AbstractList).
    The interface defines the type, and the abstract class defines a "skeleton implementation", which can be used by programmers to develop their own Lists without the hassle of having to implement the entire thing from scratch.

    One example of this kind of use, poached from "Effective Java", is an implementation of an array as a List.
    If you look at the Arrays class, you'll see that it has a method called 'asList()', whose definition looks like this:
    static T ListT asList(T... values) The idea of this method is that you can hand it a bunch of objects (or indeed an array of objects), and it will give you back a List of those same objects.

    Because AbstractList exists as a partial implementation of a List, such a method is quite easy to write, and could easily look something like this (it doesn't, but that's another story):
    static T ListT asList(final T... values) {
    return new AbstractListT() {
    public T get(int i) {
    return values;
    }
    public T set(int i, T value) {
    T oldValue = values[i];
    values[i] = value;
    return oldValue;
    }
    public int size() {
    return values.length;
    }
    };
    }and voil, an array converted to a List. Furthermore, if you hand it an array, and you later change one of the values in that array, the List will change along with it (and vice-versa; which may or may not be what you want).

    Quite powerful, when you think of all the things that a List allows you to do.

    One caveat: if you're ever extending an abstract class, you should always read its documentation extra-carefully, because it may make some assumptions that you need to know about.

    HIH

    Winston

    Edited by: YoungWinston on Feb 20, 2011 11:54 AM

  • RELEVANCY SCORE 4.14

    DB:4.14: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.14: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.06

    DB:4.06:Interfaces In Weblogicaux.Jar 1p


    Anyone had this kind of problem? Weblogic uses some org.w3c.dom.*
    classes which break our parsers code (e.g. xerces) as all the interfaces
    contain abstract methods. I wonder if I can remove the old xml stuff and
    replace it by the new jaxp and org.w3c classes without breaking
    weblogic...
    Well, I will try some classpath resorting, but a new weblogicaux.jar
    would be nice though.

    Daniel

    DB:4.06:Interfaces In Weblogicaux.Jar 1p

    Thanks for the info ... had not seen that ever.

    --

    Cameron Purdy
    cpurdy@tangosol.com
    http://www.tangosol.com
    WebLogic Consulting Available

    "Daniel Hoppe" hoppe@sitewaerts.de wrote in message
    news:74EBA7E3492BD4118B27004033E231100DFCC3@samoa.sitewaerts...
    Cameron,

    that's what I finally tried by preceding parser.jar and jaxp.jar in the
    classpath. Result was that ejb deployment breaks, I suppose due to a
    different handling of #text and #comment sections in the normalize()
    method (I'm not our XML expert, but it seems to me that the old parser
    cut out unwanted #text and #comments on normalize() while the new does
    not). We use xerces now, that's working fine - even when handling larger
    XML files. The old parser included in the jars was not able to handle
    documents of 5000lines++, I wonder wat happens if our deployment
    descriptors would happen to reach that size ...

    Daniel

    -----Original Message-----
    From: Cameron Purdy [mailto:cpurdy@tangosol.com]
    Posted At: Tuesday, October 10, 2000 4:12 AM
    Posted To: xml
    Conversation: Interfaces in weblogicaux.jar
    Subject: Re: Interfaces in weblogicaux.jar

    Daniel,

    Yes you can. Just remove all old versions from the weblogic install
    (including from inside the jars) and put the updated one in.

    --

    Cameron Purdy
    cpurdy@tangosol.com
    http://www.tangosol.com
    WebLogic Consulting Available

    "Daniel Hoppe" hoppe@sitewaerts.de wrote in message
    news:74EBA7E3492BD4118B27004033E231100D8EE7@samoa.sitewaerts...
    Anyone had this kind of problem? Weblogic uses some org.w3c.dom.*
    classes which break our parsers code (e.g. xerces) as all theinterfaces
    contain abstract methods. I wonder if I can remove the old xml stuffand
    replace it by the new jaxp and org.w3c classes without breaking
    weblogic...
    Well, I will try some classpath resorting, but a new weblogicaux.jar
    would be nice though.

    Daniel

  • RELEVANCY SCORE 4.06

    DB:4.06:Abstract Classes Vs Interfaces ma


    hi all
    Can any one explain me when to use abstract classes and when to use interfaces. I get confused on this

    pl help

    regards
    sundar

    DB:4.06:Abstract Classes Vs Interfaces ma

    hi,
    thanx a lot for your help

    regards
    sundar

  • RELEVANCY SCORE 4.01

    DB:4.01:Why Interfaces Why Not Abstract Classes? m8


    why they are using interfaces concept in JDBC or struts2.0 why not abstract classes?
    thanks in advance.

    DB:4.01:Why Interfaces Why Not Abstract Classes? m8

    why they are using interfaces concept in JDBC or struts2.0 why not abstract classes?If they had used abstract classes you would be asking why they didn't use interfaces.

    It's a pointless question. Who actually cares?

  • RELEVANCY SCORE 3.99

    DB:3.99:Abstract Classes aj


    Hi to alll.

    Can any of you to tell me some url for abstract classes code sample and tutorial?

    Thanks

    Cata

    DB:3.99:Abstract Classes aj

    Not sure why you are posting this in the J2EE patterns forum. Sounds like you need some basic OO education. There are some great articles on Javaworld. I'd browse there first.

  • RELEVANCY SCORE 3.98

    DB:3.98:Deciding Factors Between An Abstract Class And An Interface x7


    Hi,
    I have some good experience developing applications, and have started moving from being a developer to being an architect. My question is very simple, but I always find myself confused when deciding between abstract class and an Interface. A couple of the
    differences I know are:
    1. Abstract classes should be used if we know some of the functionality is going to be inherited, and some will be decided by the child classes themselves. Interfaces however dont provide such functionality.
    2. Abstract classes should be used in case we know the child classes in advance e.g. Vehichle can be an abstract class as we know the derived classes will have same functionality.

    My question :
    What factors should I consider when I have to decide between an abstract class and an Interface.
    Thanks
    Vijay KoulThanks Vijay Koul

    DB:3.98:Deciding Factors Between An Abstract Class And An Interface x7

    In my opinion its best to always go with an interface. The reason is that code-reuse through inheritance never works[citation needed][dubious]. Reaching for composition rather than inheritance has always suited me well. Writing a few bridge methods to
    implement an interface is somewhat cumbersome, but (IMO) worth it.

  • RELEVANCY SCORE 3.94

    DB:3.94:Abstract Class X Interfaces 3a


    1.The Java language has two similar concepts : Abstract Classes and Interfaces. So, When its better to use one or other technique and the advantages and disadvantages of each one ?

    DB:3.94:Abstract Class X Interfaces 3a

    http://www.javaworld.com/javaworld/javaqa/2001-08/03-qa-0831-interface.html

  • RELEVANCY SCORE 3.91

    DB:3.91:Abstract Classes 9a


    Hi to alll.

    Can any of you to tell me some url for abstract classes code sample and tutorial?

    Thanks

    Cata

    DB:3.91:Abstract Classes 9a

    try www.google.com, type in
    java abstract example

    second hit gets you this

    http://www.fluffycat.com/java/JavaNotes-Abstract.html

  • RELEVANCY SCORE 3.89

    DB:3.89:Classcastexception With Document 1c


    I have an abstract class implements DOM Document.

    public abstract class XDataDoc implements Document {
    .....
    }

    I get ClassCastException when I try to parse and XML.

    ...
    public XDataDoc xDataDoc ;
    ...

    factory = DocumentBuilderFactory.newInstance();
    parser = factory.newDocumentBuilder();
    xDataDoc = parser.parse("http://url");
    ...

    I have the same problem also with the classes implements Node or NodeList. I need this custom Document to use as a data source.
    What am I doing wrong? Is there a better way than creating a class implements Document? (Shall I create an interface extends?)
    Any help about extends / implements abstract classes and interfaces will be great useful. (I am still a newbie as you will understand)
    Thanks in advance.

    DB:3.89:Classcastexception With Document 1c

    In big picture I need to get rows and columns from database.
    With a clever Document implement I can write less code in the data entry screens.

  • RELEVANCY SCORE 3.88

    DB:3.88:Abstract Classes Vs Interfaces xz


    What is the use of an abstract class when we have interfaces?As far as i know abstract classes cannot be inherited and yes they do provide you the facility of implementing all or some of the concrete methods defined in them.Can anyone define this concept please

    DB:3.88:Abstract Classes Vs Interfaces xz

    I experienced the love of god in reply#8 of this thread: http://forum.java.sun.com/thread.jspa?forumID=31threadID=5182308

    And I got a bit crazy in reply#9. Ah well.

    Steve Vai has a song called For The Love Of God. Where's filestream? He must be slipping.

  • RELEVANCY SCORE 3.88

    DB:3.88:Documentation Formats For Interfaces, Classes, Abstract Classes 1c


    I am writing docs and want to make sure it conforms to best practices. Here is what I am doing:

    interfaces = [italics, not bold]
    classes = [not italics, bold]
    abstract classes = [italics, bold]

    I am most unsure of abstract classes?
    That is important to me, so please help me get this straight. thanks.

    DB:3.88:Documentation Formats For Interfaces, Classes, Abstract Classes 1c

    Everybody knows that interfaces are blue, classes are red, and abstract classes use jumpy text.

    (that was a joke by the way)

    To my mind, using bold for abstract classes would be misleading. Just on an intuitive level, bold seems more concrete. But that's just me. I think the best thing to do is just to decorate the names with "interface" or "abstract" so there's no confusion.

  • RELEVANCY SCORE 3.88

    DB:3.88:Is The Inclusion Of Abstract Classes And Interfaces Really Needed In Unity Game Development? m7



    It's possible to use abstract classes and interfaces in Unity, yes.


    Should you use them? I don't know. Do you need to use them?


    Some useful tips:



    Public interface type fields can't be set via the inspector.


    Public abstract class type fields can be set via the inspector.


    You can't use polymorphism on System.Serializable tagged classes or you will experience type slicing.


    You can get components implementing an interface via GetComponent(typeof(MyInterface)) but you can't use the generic version.



    As a rough guide:



    Normal classes extending from MonoBehaviour are easy and works for most problems you need to solve


    Normal sub-classes works as you'd expect. If your goal is code reuse favor composition over inheritance.


    Abstract classes are not much harder to use (remember you need a concrete implementation)


    Interfaces are working against you if exposed in public fields, shown in the inspector



    From my experience, abstract classes can better be used as interfaces (just leave all methods abstract). I say better, because at least you can serialize the references properly. However you can only inherit from a single abstract class (or chain them). Interfaces have the benefit that you can implement multiple interfaces. You can't do the same for abstract classes.


    You will also carry the baggage of MonoBehaviour. This can be both a relief and an annoyance.

    public abstract class Explosive : MonoBehaviour
    {
    public abstract void Explode();
    }




    I really haven't found the need to structure the code in such a way which includes abstract classes or interfaces for example.



    This is a good thing, generally. You should favor composition over inheritance. Unity makes it very easy to do this and you should favor composition when you have no need for inheritence. However it gets awkward when you want to decouple from Unity, like if you want to run Unit Tests separately.


    If you feel lost on the topic of composition over inheritence, I suggest you pick up a book on design patterns as they will discuss it until your ears bleed. One that I found good was Head First: Design Patterns but there are more canonical books on the subject like Design Patterns: Elements of Reusable Object-Oriented Software by the gang of four. I found Head Firsts book to be very easy to follow and I've had a lot of use of the skills it taught me.


    If you don't know what Unit Testing is, I can recommend a book called The Art of Unit Testing which I found good.

    DB:3.88:Is The Inclusion Of Abstract Classes And Interfaces Really Needed In Unity Game Development? m7


    It's possible to use abstract classes and interfaces in Unity, yes.


    Should you use them? I don't know. Do you need to use them?


    Some useful tips:



    Public interface type fields can't be set via the inspector.


    Public abstract class type fields can be set via the inspector.


    You can't use polymorphism on System.Serializable tagged classes or you will experience type slicing.


    You can get components implementing an interface via GetComponent(typeof(MyInterface)) but you can't use the generic version.



    As a rough guide:



    Normal classes extending from MonoBehaviour are easy and works for most problems you need to solve


    Normal sub-classes works as you'd expect. If your goal is code reuse favor composition over inheritance.


    Abstract classes are not much harder to use (remember you need a concrete implementation)


    Interfaces are working against you if exposed in public fields, shown in the inspector



    From my experience, abstract classes can better be used as interfaces (just leave all methods abstract). I say better, because at least you can serialize the references properly. However you can only inherit from a single abstract class (or chain them). Interfaces have the benefit that you can implement multiple interfaces. You can't do the same for abstract classes.


    You will also carry the baggage of MonoBehaviour. This can be both a relief and an annoyance.

    public abstract class Explosive : MonoBehaviour
    {
    public abstract void Explode();
    }




    I really haven't found the need to structure the code in such a way which includes abstract classes or interfaces for example.



    This is a good thing, generally. You should favor composition over inheritance. Unity makes it very easy to do this and you should favor composition when you have no need for inheritence. However it gets awkward when you want to decouple from Unity, like if you want to run Unit Tests separately.


    If you feel lost on the topic of composition over inheritence, I suggest you pick up a book on design patterns as they will discuss it until your ears bleed. One that I found good was Head First: Design Patterns but there are more canonical books on the subject like Design Patterns: Elements of Reusable Object-Oriented Software by the gang of four. I found Head Firsts book to be very easy to follow and I've had a lot of use of the skills it taught me.


    If you don't know what Unit Testing is, I can recommend a book called The Art of Unit Testing which I found good.

  • RELEVANCY SCORE 3.88

    DB:3.88:Abstract Classes Vs. Interfaces s3


    hi friends,
    Why should a programmer create an abstract class instead of an interface?
    thanks

    DB:3.88:Abstract Classes Vs. Interfaces s3

    @Derek:
    Scotland! Never been there.
    Closest I've come is passing through Heathrow going to and from another destination.
    I am fairly well settled in NYC, though. Thanks.
    ============================================================
    I like your solution because it is more abstract. No references to concrete classes, pass an interface for a parameter, and pass an interface back as a return object. I would suggest one improvement, though, on the return object.
    Covariance and Contravariance in Generics

    Instead of IList, I might be more inclined to use IEnumerableT. Now you need to specify a generic type. Perhaps, an IPerson interface could do the trick.
    Rudy =8^D

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

  • RELEVANCY SCORE 3.88

    DB:3.88:Non-Abstract Methods In A Abstract Class fj


    Abstract Class can contain Non-abstract methods.
    and Abstract Classes are not instantiable as well
    So,
    What is the purpose of Non-abstract methods in a Abstract class.
    since we can't create objects and use it

    so these non-abstract methods are only available to subclasses.
    (if the subclass is not marked as abstract)
    is that the advantage that has.(availability in subclass)

    ??

    DB:3.88:Non-Abstract Methods In A Abstract Class fj

    so these non-abstract methods are only available to
    subclasses.If they're public, they're available to any user of the class or of its concrete subclass. Same as the abstract metods. Same as interface methods. Same as public methods in a concrete class.

  • RELEVANCY SCORE 3.88

    DB:3.88:Interfaces And Abstract Classes 1a


    Iam new to java.i always confuse in using interfaces and abstract classes.
    when do we use interfaces and when do we use abstract classes.if possible give small scenario.

    thanq,regards
    venkat.a

    DB:3.88:Interfaces And Abstract Classes 1a

    njoy wrote:
    i agree you can also consider interfaces like moulds that the class calls on

    abstract methods moulds which the caller has to fill inHow can you call on a mould? I don't know what you are even trying to say here, but your analogy still seems misplaced. You seem to be remarking on the difference between a client using a type:

    void f(Type t) {
    t.method();
    }and defining a class that extends a class/implements an interface.

  • RELEVANCY SCORE 3.85

    DB:3.85:Some Conceptual Questions?? p8


    1- what is the purpose of java interfaces ... Dont you think that with only abstract classes we can build an application. In that case we dont require interfaces

    2- what if java interfaces were not there, would a complex java application be possible ?

    3- Suppose there are no interfaces in java, which functionality in particular will be missing?

    4- why abstract classes? As we cannot instantiate abstract classes then what is the purpose behind all this..

    5- Is overloading a form of polymorphism? If yes, why? Because concept of polymorphism is, i believe, only possible in inheritance.

    DB:3.85:Some Conceptual Questions?? p8

    Hi Ali,

    1- what is the purpose of java interfaces ... Dont you think that with only abstract classes we can build an application. In that case we dont require interfaces

    Interfaces in concept are contracts between tow entities, it means that one entity says to the other if you want to speak to me you must speak in this language. So the other entity will speak in that language and chooses what words to say based on the situation.

    In the Java world it means that one entitiy will require the other to implement the given interface so it will be sure that its contract (set of methods) will not be violated and the implementor entity is free in how to provide the implementation for these methods.

    4- why abstract classes? As we cannot instantiate abstract classes then what is the purpose behind all this

    Abstract classes are used for the same reason as Interfaces (it is a contract) but it has some more restriction, Meaning that it might provide concrete implementations for parts of that contract sothat the implementor (or in this case the extending class) can provide implementations only for the rest of the contract.

    Abstract classes can't replace interfaces, remember in java you have single-inhertance, so if you extended the abstract class you wasted your opportunity and you can't extend another one.

    5- Is overloading a form of polymorphism? If yes, why? Because concept of polymorphism is, i believe, only possible in inheritance.

    Yes, polymorphism means you have diffrent METHODS to perform the same FUNCTION.

    So assume you have a function named getPrice and you can return the price in USD or GBP, then you need to have 2 overloaded methods, one takes no-args and return USD and the other takes a string arg and returns price in given currency.

    Hope this will help you understand the concepts.

    ---------------------------------------------------------
    Only by helping each other, we can grow

  • RELEVANCY SCORE 3.85

    DB:3.85:Recommendation For Naming Of Contractclassfor Helper Classes For Interfaces? pc


    What is recommended naming convention for 'ContractClassFor' helper classes ?
    The sample in 2.9 uses the format:
    abstract class Iinterface-nameContract
    Section 4.1 uses the format:
    class ContractForinterface-name
    Most of the standard assemblies that ship with code contract seem to use the 2.9 format. This format generates however fxcop/stylecop warnings as names starting with 'I' are reserved for interface types and not abstract classes.

    DB:3.85:Recommendation For Naming Of Contractclassfor Helper Classes For Interfaces? pc

    I use:

    ClassName IClassName ClassNameContract
    Then it's obvious by the filenames what those files actually are. I usually create a seperate project for the interfaces and put the contracts in a subfolder called Contracts.
    R.

  • RELEVANCY SCORE 3.85

    DB:3.85:Re: Can I Extend 2 Abstract Classes? 1j


    It appears to be imposible to extend 2 abstract
    classes

    like this:

    public class Foo extends AbstractClass1,
    AbstractClass2

    maybe there is some other way?You cannot extend more than one class. Create two interfaces instead and implement them in a class.

    public class Foo implements Interface1, Interface2 {
    ...
    }That's the only way of having multiple inheritance in Java.

    Cheers!
    ***Annie***

    DB:3.85:Re: Can I Extend 2 Abstract Classes? 1j

    Hi,
    When there is no multiple inheritence proviion in
    Java, how is it possible for an interface to 'extend'
    more than one interface ?Because Java supports multiple inheritance of interface, just not MI of implementation. It's an important distinction. Classes implement interfaces, but interfaces extend other interfaces (it wouldn't make sense for an interface to implement an interface, since interfaces provide no implementation). And since interfaces provide no implementation, the dangers of MI/implementation don't exist, and so extending multiple interfaces is allowed.

  • RELEVANCY SCORE 3.84

    DB:3.84:Abstract Vs. Interfaces j1


    I wanna know that when we should use abstract classes and when we should use interfaces(from a design view).

    regards,

    DB:3.84:Abstract Vs. Interfaces j1

    I wanna know that when we should use abstractclasses
    and when we should use interfaces(from a design
    view). Who said it's "either or"? Use interfaces if you have
    common contracts and abstract classes if you have
    common implementation.Indeed. In 8-10 years of almost nonstop Java programming, I don't think I've ever asked myself, "Should I make an interface or an abstract class?"

    Look at the javadocs and source code for java.util....

    Collection
    List
    Set
    AbstractCollection
    AbstractList
    ArrayList
    LinkedList
    AbstractSet
    HashSet

    ...

    etc.

    ...

  • RELEVANCY SCORE 3.82

    DB:3.82:Need Some Concept Clearence!!! pd


    1- what is the purpose of java interfaces ... Dont you think that with only abstract classes we can build an application. In that case we dont require interfaces

    [b ]2- what if java interfaces were not there, would a complex java application be possible ?

    3- Suppose there are no interfaces in java, which functionality in particular will be missing?

    4- why abstract classes? As we cannot instantiate abstract classes then what is the purpose behind all this..

    5- Is overloading a form of polymorphism? If yes, why? Because concept of polymorphism is, i believe, only possible in inheritance.

    DB:3.82:Need Some Concept Clearence!!! pd

    yeah i knw that u can implement many interfaces, but
    when u inherit classes, u . actually inherit all the
    functionality as well Use real words with proper spelling, punctuation, and capitalization.

    But in the case of interfaces, they have no
    functionality, so wats the purpose...??Inheritance is not about "functionality." It's about type. The fact that you also get to inherit implementation in the case of classes is just a bonus.

  • RELEVANCY SCORE 3.81

    DB:3.81:Abstract Classes And Interfaces 97


    HiCan anyone explain me the difference betweeen the abstract class and interfaces?What is the use of the interfaces?How can we inherit multiple Interfaces?Can anyone please explain my above questions in simple words.?

    DB:3.81:Abstract Classes And Interfaces 97

    David,You are correct, I did not notice that he was inheriting from the other interfaces. My bad. I should have paid more attention in my answer.Of course, the next step in all of this would be to explain explicitly implementing the interface, and what would happen if IOne and IThree (for example) each had methods named someOperation. But I think the OP is good for now :)ChrisChris Snyder, Stumbling through code one day at a time

    If your question was answered, please mark it.

  • RELEVANCY SCORE 3.79

    DB:3.79:Abstract Classes a7


    Is it possible for an abstract class to have both abstract methods and non-abstract methods?

    public abstract class Person
    {
    private String name;

    public Person(String n)
    { name = n;}

    public String getName()
    {return name;}

    public abstract String getAddress();

    }And can a non-abstract class have abstract methods?

    DB:3.79:Abstract Classes a7

    An abstract class can have both abstract methods and non abstract method i,e the regular methods , but a non abstract class cannot have abstract methods. from this what we get is that its a must to have the class as abstract whenever you have a abstract method in it.

    if u add an abstract method in a simple class it will throw a error saying that u can only define an abstract metod in an abstract class.

  • RELEVANCY SCORE 3.78

    DB:3.78:Interfaces And Abstract Classes 7k


    Hi! All,

    I have had a small doubt about Interfaces and Abstract Classes ... and
    I would like to discuss it with you
    In Case of Java do we only have interfaces to support multilple
    inheritance(indirectly though). I mean all other functionalities of
    interface can be provided by abstract classes. So is there any other use
    in JAva for interfaces except of course providing multiple inheritance.

    Regards

    vikram

    DB:3.78:Interfaces And Abstract Classes 7k


    To not side step the question, I would say that there
    is no other reason. It can be a nice way of sharing constants accross a program (when they really are constant).

  • RELEVANCY SCORE 3.78

    DB:3.78:Re: Instanciate Interface cm


    So I suppose I can also assign an abstract class to an interface then.. but
    abstract classes cannot be instanciated...so cant do that right?As you already noticed, abstract classes as well as interfaces can not be instantiated,
    but nothing forbids you to instantiate a concrete class, derived from the abstract
    class or an interface and just refer to it as if it were just the abstract class or
    interface, e.g.interface Something { void doSomething(); }
    public abstract class AbstractSomething implements Something { }
    public class DoesIt extends AbstractSomething {
    public void doSomething() { System.out.println("doing something ..."); }
    }
    ...
    Something a= new DoesIt(); // fine
    AbstractSomething b= new DoesIt(); // fine
    DoesIt c= new DoesIt(); // fine
    Something d= new Something(); // error: can't instantiate interfaces
    Something e= new AbstractSomething(); // error: can't instantiate abstract classkind regards,

    Jos

    DB:3.78:Re: Instanciate Interface cm

    Hi Jos,

    My question was

    so I am assigning the Collection's variable a
    reference to the ArrayList object.or
    Something a= new DoesIt(); // fine
    AbstractSomething b= new DoesIt(); // fine

    I am assigning Something's variable, a reference to
    the DoesIt.... so Somthing hold a reference of type
    DoesIT but it just sounded a little wierd because
    Something was an interface...

    I get it now though... one can assign a variable a
    reference as long as the reference is of a concrete
    class.... even if that variable belongs to an
    interface.Your terminology is really wonky, so it's hard to guage whether you really understand.

    The variables we're talking about here hold references. Those references point to objects.

    The reference variable has an associated type, indicated where it's decleared--Collection, List, String, etc.

    The object that you point the reference variable at must be of a type that is assignment compatible with the declared type of the variable.

    That's all there is to it, unless you're not clear on the rules about assignment compatibility (subclasses, implementing classes, etc.)

  • RELEVANCY SCORE 3.77

    DB:3.77:Dependency Injection/Inversion Of Control Question... zk


    Using the principals in the subject, am I correct in believing that all classes should use Interfaces or Abstract Classes when establishing associations between classes?
    If I had a Car class, it'd be proper to have a ListIPart property instead of
    ListPart... and if each part had associations with things like Suppliers, Categories, etc... all those should be Interfaces as well?

    Seems like a ton of work.

    DB:3.77:Dependency Injection/Inversion Of Control Question... zk


    Using the principals in the subject, am I correct in believing that all classes should use Interfaces or Abstract Classes when establishing associations between classes?

    Like Reed, I disagree, in practice no class should be abstract nor implement an interface unless there's a value to do so!

    In my opinion and I've seen it in practice, developers tend to over abstract programs because they either work in a top-down approach or they don't really think about the overall structure and abstract everything.
    Working from top to bottom (top-down) means you first define your interfaces (specification) and only then implement them whereas in the opposite approach, you first have a real or concrete implementation in place and then you extract the interface from
    the actual implementation, working up as the application evolve.

    In my experience when you're using top-down you're doing too many assumptions and you have absolutely no idea how everything will play out at the end, however, I guess that it all comes to the way you think as a person about problems and the approach
    you're taking to solve them.

    Seems like you would need to have some awesome foresight to know which classes are less likely to change. In my situation, the Parts class, I would think is more apt to change... and a supplier would be less likely to change, but that's just me stabbing
    in the dark. Is there any logic test engineers use to answer this question?

    You don't need and shouldn't make any assumptions, it's science for a reason, you should
    know where and what is going to change as the application evolve.
    When new dependencies are created you have the chance and choice to either make everything dependent on a certain implementation or extract it to an interface and make the new code dependent on this interface.

    Regards,

    Eyal Shilony

  • RELEVANCY SCORE 3.74

    DB:3.74:Abstract Class Question x1


    is it possible to create instances of abstract classes? I know you cant do it for interfaces.

    DB:3.74:Abstract Class Question x1

    Abstract classes cannot be instantiated using a constructor as any attempt to do that would be a compile time error. If you have a need to instantiate it, either don't make it abstract or subclass it. You can also add a private constructor and have it create an instance using a factory method. What exactly are you trying to do?

  • RELEVANCY SCORE 3.71

    DB:3.71: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.71: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.70

    DB:3.70:Java Interfaces And Abstract Classed fc


    what is the difference between interface and abstract class?

    DB:3.70:Java Interfaces And Abstract Classed fc

    I suggest you try writing some code and see.

  • RELEVANCY SCORE 3.70

    DB:3.70:Interfaces And Abstract Classes cd


    Interfaces and Abstract Classes

    I read the paragragh bellow in a java book, it explains the question that many people asked in the forum.

    If you read the section about abstract classes in Chapter 5, you may wonder why the designers of the Java programming language bothered with introducing the concept of interfaces. Why can't Comparable simply be an abstract class:

    abstract class Comparable // why not?
    {
    public abstract int compareTo(Object other);
    }The Employee class would then simply extend this abstract class and supply the compareTo method:
    class Employee extends Comparable // why not?
    {
    public int compareTo(Object other) { . . . }
    }There is, unfortunately, a major problem with using an abstract base class to express a generic property. A class can only extend a single class. Suppose that the Employee class already extends a different class, say, Person. Then it can't extend a second class.

    class Employee extends Person, Comparable // ERROR

    But each class can implement as many interfaces as it likes:

    class Employee extends Person implements Comparable // OK

    Other programming languages, in particular C++, allow a class to have more than one superclass. This feature is called multiple inheritance. The designers of Java chose not to support multiple inheritance, because it makes the language either very complex (as in C++) or less efficient (as in Eiffel).

    Instead, interfaces afford most of the benefits of multiple inheritance while avoiding the complexities and inefficiencies.

    DB:3.70:Interfaces And Abstract Classes cd

    However the answer he gave is very clear :) so next time some one ask a question we can just post a link to this post, instead of writing the all same thing again or tell him go search in google.

    regards,
    sim085

  • RELEVANCY SCORE 3.69

    DB:3.69:Interfaces And Abstract Classes xa


    why we have constructor for abstaract class and why we do not have any constructor for the interface

    DB:3.69:Interfaces And Abstract Classes xa

    Dear,

    I am a Java Guru but I can share some ideas about abstract class and interface.

    Your question is when to use abstract class and interface?

    These two act similarly. You should note SIMILARLY which is not the SAME. The same purpose of these two is enable us to use "polymorphism". Without the polymorphism, these two are nothing. (You should find out yourself what the polymorphism is?). And the differences between these are:

    1 - Abstract class is a class. It is really a class. That is, you can inherit features from it.
    Whereas the Interface is not a class. It means you cannot inherit features from it. (You may raise a question that it is not true! But it is true!) However, its purpose is to add features to our class.
    That's why, you can see we use extends keyword to inherit abstract class which is the same to other usual classes (concrete classes) and we use implements keyword for interface.

    2 - Java doesn't allow multiple inheritance. So how can you inherit more than one abstract class. Instead, you have to create one abstract class and many interface.

    3 - If you understand about relationship between classes: IS-A and HAS-A, it is easy to understand. For example,
    - "A duck is a bird". Is it always true? It is true, right! Therefore the bird is the abstract class and the duck is a sub class.
    - "A duck is flyable". Is it always true? Not always. Not all ducks can fly. Therefore the flyable is the interface. Note that the name of interface usually has "able". That means it is just a functionality.

    Conclusion

    The abstract is used to be a PARENT of a group of sub class. For example, in the Java library, you will see Number is parent a group of numbers, AbstractButton is a parent of buttons. Whereas Interface is just only a feature that is used to add a functionality to our class when needed. For instance, Compareable is used only when you need to compare things. You don't ALWAYS need it, right? Also, ActionListener is needed when you want a button clickable. But when you only need keyboard press, you don't need the ActionListener interface.

    I hope this will be helpful for you. ;-))

  • RELEVANCY SCORE 3.69

    DB:3.69:Re: Inteface Vs Abstract Class dd


    interfaces are implented, abstract classes are extended. In an interface ther is no code or variables only methods and any class that implements the interface must provide code implementation for all the methods. An abstract class has code. Why you would use them i have no idea or i jsut fogot

    DB:3.69:Re: Inteface Vs Abstract Class dd

    Joshua Bloch has something to say about this... see the book "Effective Java" - one of the best Java books once you no longer consider yourself a beginner

  • RELEVANCY SCORE 3.69

    DB:3.69:Static Vs Abstract Classes 17


    Just wondering if anyone knows the difference between static classes and abstract classes.

    How do static methods, static variables work?

    Is there such a thing as an abstract method?

    Thanks

    DB:3.69:Static Vs Abstract Classes 17

    Ok i think its easier to understand if u see some examples:

    abstract class X{
    protected int value;
    public abstract void setValue(int pValue);
    }
    class Y extends X{
    public void setValue(int pValue) {
    this.value=pValue;
    }//each class, which extends x has to implement this method, or the class has to be //declared abstract too
    }
    class Z extends X{
    public void setValue(int pValue) {
    this.value=2*pValue;
    }
    }

    You can use this inheritance-tree as follows:

    public class try {
    public static void main(String[] args) {
    X try=new X() //NOT possible!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    X try=new Y();
    try.setValue(10); //the value-field of try has the value 10
    try=new Z();
    try.setValue(10); //the value-field of try has the value 20
    }
    }

    The techinque i used above is called "dynamical linking" and is one of the advantages of an objectoriented language.

    The main difference of abstract and static is, that you can't instantiate an abstract class direct.

    A static class or a static method and variables has just one (and only one!!) represantation during runtime. And if you want to change the value of a static variable within a method this method has to be static too.

    Example:
    public class StaticTest {
    static int counter;
    public StaticTest() {
    counter++;
    }
    public static void print() {
    System.out.println(this.counter);
    }
    }
    public class TestClass {
    public static void main(String[] args) {
    StaticTest test;
    for (int i=0;i10;i++) {
    test=new StaticTest();
    }
    StaticTest.print(); //the output would be 10!!!!!!!!!!!!!!
    }

    }

    I hope this helps

  • RELEVANCY SCORE 3.68

    DB:3.68:Can Anybody Tell Me The Real Time Application For Interfaces And Abstract Classes??Plz a3


    can anybody tell me the real time application for interfaces and abstract classes??plz..thanks in advancehashna

    DB:3.68:Can Anybody Tell Me The Real Time Application For Interfaces And Abstract Classes??Plz a3

    @David, He actually wants to know the differences between interfaces and abstract classes in a real world applications and not real time computing. :p
    Eyal (http://shilony.net), Regards.

  • RELEVANCY SCORE 3.68

    DB:3.68:Application Development Using C#. 9a


    Hi this is Sushil. I want to know the Interfaces and abstract Classes and thier user?

    DB:3.68:Application Development Using C#. 9a

    Hi this is Sushil. I want to know the Interfaces and abstract Classes and thier user?

    There have been many discussions of this in the past on the forums. I recommend reading this thread:
    http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/d9ebdfca-18e7-4d73-89b4-5087d038f784

    Also, I moved this thread into Visual C# Language, as it's a pure language issue, and not related to WPF.Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click Mark As Answer on that post and Mark as Helpful.

  • RELEVANCY SCORE 3.68

    DB:3.68: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.68

    DB:3.68:Abstract Classes Vs. Interfaces zd


    Hi,
    I have 2 basic questions that I'd like answers for:
    1) What is the exact difference(s) between abstract classes and interfaces? --
    2) Where are they used, and why are they preferred in their respective areas of usage?
    I've gone through some books (CORE JAVA, THE COMPLETE REFERENCE,etc.) as well as some online documentation (by Bill Venners, Paul Rogers, Peter Kriens, etc.) and I'm stil confused.
    I'd be glad if someone could shed a little light on this with as little ambiguity as possible.
    Thanx a ton!!!!!!!!!
    TheJavaKid

    DB:3.68:Abstract Classes Vs. Interfaces zd

    Hi,
    I have 2 basic questions that I'd like answers for:
    1) What is the exact difference(s) between abstract
    classes and interfaces? -- The first answer gives a good description, but it may be useful to understand the distinction in terms of an example. One class can implement multiple interfaces, that is, present different views on itself to various objects. I might have some GUI class that implemented ActionListener, KeyEventListener, ListSelectionListener etc etc. As such it registers itself with the various "observables" (ie. a JButton, a JTextField and a JList). The JList should no more be able to call keyTyped() than it should any of the other methods on the GUI class - it can only see the view of the class encapsulated by its valueChanged() method. This has advantageous implications for all sorts of things, in particular the authors of javax.swing implemented the Listeners as interfaces (not abstract classes) so that objects could be more than one thing at a time - remember of course that there is no multiple inheritance in Java.

    However, if you are writing an application, you may feel that it violates encapsulation that a single object implements more than one interface and hence may instead define some type as an abstract class, even if the class has no implementation details whatsoever. By this I mean that you may have 2 "types" within your system which you could define as interfaces but of which you would rather restrict users from defining a class that is simultaneously "both" of these things.

  • RELEVANCY SCORE 3.67

    DB:3.67:Help! 37


    Hello! Everybody
    I am new to programming
    I am learning java
    i am interested to know the difference between interfaces and abstract classes in java

    DB:3.67:Help! 37

    JavaIsMyThing wrote:
    If you create a class that implements an interface, you are required to supply an implementation for ALL of the methods that are declared in the interface you implement.Not if the class is declared abstract.

    ~

  • RELEVANCY SCORE 3.67

    DB:3.67:Class Declaration 1s


    hi all can classes be both final and abstract?

    DB:3.67:Class Declaration 1s

    Hi Olaf,that was an intersting thing you pointed out.But I still fail to justify allowing a class that is both abstract and final.The usage that you mentioned should be actually served by an interface.I also noted that the syntax check allows a class to be both final and abstract although an abstract method may be defined in it. This is again meaningless.Zakir

  • RELEVANCY SCORE 3.66

    DB:3.66:Interfaces And Abstract Classes 8x


    Whats the difference between an interface and an abstract class.

    DB:3.66:Interfaces And Abstract Classes 8x

    Another trait that is often overlooked is that the abstract methods and constants declared in an interface are always public; with abstract classes, you can declare them (package) and protected scope as well.

  • RELEVANCY SCORE 3.65

    DB:3.65: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:3.65: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 3.65

    DB:3.65:Difference Between Abstract Classes And Interfaces 9p


    I actually wonder about what are the differences between abstract classes and interfaces may somebody give an example code about it?

    and i have one more question how can i use interfaces like multiple inheritance ? i mean when i implement an interface like

    class a extends b implements c,di have to use all c and d methods but what that methods means?
    I mean as i know we cannot make implementations of methods in interfaces
    but for example in runnable interface there is a method like run() and it has been defined somewhere because it knows what to do(i mean when it will run), i just write my code into that method .

    DB:3.65:Difference Between Abstract Classes And Interfaces 9p

    Abstract classes are the classes that act as super
    classes and must be inherited by the derived
    classes.They provide methods to be implemented in the
    derived classes . whereas interfaces are the ones
    that are not inherited but instead implemented in the
    derived classes.Implementing an interface is also inheritance.

  • RELEVANCY SCORE 3.63

    DB:3.63:How To Get 2 Different Classloader In One Jvm? fj


    I call ClassLoader.getClassLoader() and Thread.currentThread.getContextClassLoader() but i always get the same ClassLoader instance.
    I want to load my interfaces and abstract classes by one ClassLoader and load my concrete classes by another ClassLoader.How can i achieve this?

  • RELEVANCY SCORE 3.63

    DB:3.63:Interface And Abstract Classes cz


    Hi! All,

    I have had a small doubt about Interfaces and Abstract Classes ... and
    I would like to discuss it with you
    In Case of Java do we only have interfaces to support multilple
    inheritance(indirectly though). I mean all other functionalities of
    interface can be provided by abstract classes. So is there any other use
    in JAva for interfaces except of course providing multiple inheritance.

    Regards

    vikram

    DB:3.63:Interface And Abstract Classes cz

    I'll give you a short and powerful answer for the need of interfaces: polymorphism.

    Nikita

  • RELEVANCY SCORE 3.63

    DB:3.63:Use Of Wrappers, Interfaces, Etc 7s


    Hi,
    I am looking at someone else's code and they have used the concept of Wrappers, Interfaces, Abstract Classes, etc.
    I would like to learn how to use this and to understand it all. Can anyone recommend good books/tutorials for this?
    Thanks!

    DB:3.63:Use Of Wrappers, Interfaces, Etc 7s

    Please findWrapper,Abstract
    factory, abstract type and interface.
    Detailedpattern reference can be foundhere.

    If this post answers your question, please click Mark As Answer. If this post is helpful please click
    Mark as Helpful.

    Regards,
    Nairs

  • RELEVANCY SCORE 3.62

    DB:3.62:Interface Classes m9


    can somebody tell me why interface classes are useful.. right now i'm just not convinced, because, like an abstract class, interfaces only contain method headers that are to be used in derived classes. Why write another class to store the method headers when you still need to code the header again except this time there's code? Instead, can't u just write that same method in another class without implementing an interface in the first place, isn't that less coding?

    I'm just confused about abstract and interface classes, and don't know when to use them.

    Can someone explain the concepts...

    DB:3.62:Interface Classes m9

    Firstly interfaces. Look at the Java event model. If a programmer wants to register interest in someone pressing a JButton, he registers his interest with the button through the method JButton.addActionListener(ActionListener l). The parameter here is of type ActionListener which is an interface. This achieves two things. Firstly the programmer can make his whole class implement ActionListener and fill in the method. Alternatively he could make it using an anonymous inner class. Secondly, it is an issue of security - within the JButton whatever object is sent to the addActionListener method, the JButton can only "see" the ActionListener part of it - ie. the JButton can only call the actionPerformed() method.

    Let us look at another use of Interfaces - the java Collection API. Apache have various implementations of such interfaces as Map, Set, List that differ in some way from HashMap, HashSet, Hashtable, ArrayList that Java provides. Usually the difference is performance-related, such as a Map that is used for fast-lookups in a multi-threaded environment but assumes that writes are done seldomly (org.apache.commons.collections.FastHashMap being a case in point). Suppose you have written your code everywhere thus.
    public void someMethod() {
    HashMap m = new HashMap();
    callMethod( m );
    }

    private void callMethod(HashMap m) {
    //do something here
    }And then when you come to profile your application, you find that it is too slow and would be benefitted by using FastHashMap - you will have to go through every single place you have written HashMap in your code and change it. However, if you had originally done...
    public void someMethod() {
    Map m = new HashMap();
    callMethod( m );
    }

    private void callMethod(Map m) {
    //do something here
    }You won't - you will only need to change where the HashMap was Constructed. Going a bit further, had you used a Factory object to return you the new Map implementation, then wouldn't have to look through the code at all - you could merely go straight to the factory Object where all Construction is done and change it there.

    A further use of interfaces is to define an API for vendors to implement. One example of this is JDBC. The interfaces (as with the Collections API) provide a contract of behaviour.

    Abstract class are slightly different - suppose you were coding an application for a Company - you might have classes representing Employee, Manager, Customer etc etc. These will have some properties that are shared (ie. all will have contact telephone numbers, not all will have salary, or bonus etc. So you might have the hierarchy
    Person (abstract : attributes address, telephone, email)
    |
    |-- Employee (attributes salary, employeeNumber)
    | |
    | |-- Manager (attributes bonusPayment, staff[])
    |
    |-- Customer (attributes accountNumber)You would make the Person class abstract as it makes no sense to be able to instantiate a Person, only concrete sub-classes. Its subclasses can inherit its attributes (if you so wish) and also functionality (you could define a public void sendEmail(String message) on Person to be inherited by its subclasses), again if you so wish.

    I hope this helps.

  • RELEVANCY SCORE 3.61

    DB:3.61:Name Clash d3


    During compilation of our application we get some strange 'errors' that I haven't seen before. In fact the class file still appears but we'd like to get to the bottom of what 'erasure' is and why the errors might be occurring.

    Examples are:

    /BEA/jdk130/bin/javac FileExporter.java
    /d/DEV/MERGE/HW/classes/com/dstintl/interfaces/ResourceDAO.java:978: name clash: DataObjectImplementation() and DataObjectImplementation()
    have the same erasure
    public static abstract class DataObjectImplementation
    ^
    /d/DEV/MERGE/HW/classes/com/dstintl/interfaces/ResourceDAO.java:981: name clash: newDataObject() and newDataObject() have the same erasure
    public abstract DstiDAO.DataObject newDataObject ();
    ^
    /d/DEV/MERGE/HW/classes/com/dstintl/interfaces/ResourceDAO.java:982: name clash: getDynamicMetaData() and getDynamicMetaData() have the
    same erasure
    public DstiFieldMetaData[] getDynamicMetaData () {return ResourceDAO.getMetaData();}

    DB:3.61:Name Clash d3

    Pay no attention to the man behind the curtain.

  • RELEVANCY SCORE 3.61

    DB:3.61:Interface/Abstract Class ? 1m


    Hi,
    my desired (simplified) situation:

    * class Letter contains the static method write()
    * classes A,B,C extend (implement?) Letter and write()

    * in my program I want use something like this: (Letter)(Class.forName("A")).write();I've tried this in many ways (using abstract classes, interfaces) but I can't get it to work.
    Could anyone give me a hint in the right direction please?

    Many thanks.

    DB:3.61:Interface/Abstract Class ? 1m

    You can always invoke a static method via reflection, if that's your requirement, though usually it's not the best way.

    Pete

  • RELEVANCY SCORE 3.60

    DB:3.60:Need For Interface??? ff


    What is the need for Interfaces when we have Abstract classes? I mean is there anything that can be achieved by Interface but not by an Abstract class?

    DB:3.60:Need For Interface??? ff

    well no, interfaces are not just to implements mutliple inheritance.

    Go find all the other topics study tutorials but never just assume that interfaces are just to implements mutliple inheritance.

  • RELEVANCY SCORE 3.60

    DB:3.60:Developing Ui Commands 7k


    Looking inside the portal implementation, it wcm.rendering contains Abstract classes to subclass and interfaces to implement, but I cannot find any docs.These libs are also not included int he Eclipse PDK plug-in.Anyone having experiences with developing custom UI commands with the PDK?

    DB:3.60:Developing Ui Commands 7k

    Hi SvenI have also been working on some changes to the flexible UI, but I've had some problems deploying the code to the server. Did you re-package your changes into the standard SAP uiflex library or did you manage to deploy it as a separate library?My code works when uploaded to the portal as a service, but when restarting the server I get an error saying dependent classes are not available. Apparently there is some classloading problems with my code.Kenneth

  • RELEVANCY SCORE 3.59

    DB:3.59:Re: Interface Or Abstract Class xa


    its true that the question has been answered many times and its always good to read books, but having said that it is a valid question!

    @ OP
    interfaces should be used for peripheral abilities of a class while abstract classes for central indentities. e.g Both mammal and plant might implement growable while abstract classes would be more concrete

  • RELEVANCY SCORE 3.58

    DB:3.58:Re: Abstract Classes And Descriptors 97


    Any ideas? this is blocking me. thanks

    DB:3.58:Re: Abstract Classes And Descriptors 97

    You must setup inheritance in your descriptors with a type indicator (discriminator) in the root Account descriptor for each concrete subclass. If there is no indicator value for Account then TopLink will not try to instantiate it during initialization.

    Doug

  • RELEVANCY SCORE 3.58

    DB:3.58:Interfaces af


    Please send the Answers to the following Questions.

    1)When an interface is used an when an abstract classes are used.

    2)Ehat is the diffence between Synchronized and Block.

    3)Write your own Exception class.

    DB:3.58:Interfaces af

    Interfaces are more efficient because they require less code.

  • RELEVANCY SCORE 3.57

    DB:3.57:Re: Interfaces Are Slower Than Abstract Class s1


    java methods are dynamically bound, no matter what source object they appear to belong to. I really hope you're not making design decisions such as "we'll use concrete classes here because they're faster"

    you won't get an explaination of when to use abstract classes or interfaces. it gets asked every day, and it's such a tiresome explaination to write out. google for it, but you won't find much of use. deciding when to use which is a judgement call, there isn't a handy rule-of-thumb, other than the one the language constructs themselves imply quite loudly

    DB:3.57:Re: Interfaces Are Slower Than Abstract Class s1

    Are u software engg or automobile engg. You canwrote
    aanswer to my question in same line u worte allthis.

    ok then. use interfaces when dealing with a database
    on another machine, and abstract classes when it's
    local. Except for the mauve ones, obviously, because they have more RAM.

  • RELEVANCY SCORE 3.56

    DB:3.56:Re: Discussion On Abstract Class And Interface fc


    Search. There are many, many, many articles and threads on the web.

    And don't dare to ask "aren't interfaces pointless if you can have completely abstract classes?" in here, like those two million people before you did.

    DB:3.56:Re: Discussion On Abstract Class And Interface fc

    this doubt is on EJB (CMP)

    please help......Now turned into a cross/multi hybrid post...

    a link to your previous post on this would have sufficed.

    http://forum.java.sun.com/thread.jspa?threadID=643839tstart=0

  • RELEVANCY SCORE 3.56

    DB:3.56:Interfaces V/S Abstract Classes???? m3


    Hi Every1
    Can anybody plz tell me the difference b/w "INTERFACE ABSTRACT CLASSES" from design prospective. I have sufficient knowledge on Interfaces and abstract classes in general, but unable to make out when should I use which one? I have read few topics on Java World and from some other sites too, but unable to makeout the difference.
    Topic on "Abstract Classes v/s Interfaces" on Java World says that if your design changes frequently then go for "Interfaces". Why?????
    That tutorial also says "Interfaces are generally used for making Framework. "HOW"????
    I have different thinking...
    Lets say there is one interface called I_Animal and an abstract class called C_Animal, which are as follows:

    interface I_Animal{
    public void move(); // Which tells how different animals move
    }

    Now my Abstract class

    class abstract C_Animal{
    public void move(); // Which tells how different animals move
    }

    Now there 2 classes namely(C1 and C2), C1 implements I_Animal to provide the functionality of move() method.
    C2 extends C_Animal(abstract class) to provide the functionality of move() method.

    class C1 implements I_Animal{
    public void move(){
    // Some functionality
    }
    }

    class C2 extends C_Animal{
    public void move(){
    // Some functionality
    }

    Now what i want to know is which approach is better and "WHY"??
    My thinking is....
    Sometimes using interfaces is advantegeous while sometimes abstract calsses are better, depending upon the requirement and situation

    Lets say in the above example, in future we want to add one more method called eat(). If we r adding eat() method in interface then we have to add the method in the class (which implements that interface) also. So in this case we have to make changes at two different places(namely interface and the implementing class), but if we are adding the move() method in abstract class, we can add it in the abstract class with blank implementation(i.e opening and closing the curly braces like this {}). Here we are not changing the code at two different places. so in this case abstract classes are advantegeous.
    Lets think of a different senario where my class is already extending some other class, then in that case I can't use abstract class because Java doesn't support Multiple Inheritance. So the only way round is to use Interfaces.
    So this is how I differentiate b/w interfaces and abstract classes. Do anyone of you have different thought on this. Plz tell me.

    Any help will be appreciated

    Tx in Advance
    Jam

    DB:3.56:Interfaces V/S Abstract Classes???? m3

    Why are interfaces useful from a design perspective? Because they are less intrusive.

    For instance, take a look at the interface Action and the abstract class AbstractAction in Swing. Say you want to add a button to a toolbar (using JToolBar). The add method accept any object that has type Action. This means that you can add any instances of your own classes with the only requirement that they implement the Action interface. However, if add was designed to take an instance of type AbstractAction, then you would be forced to make your own class inherit from AbstractAction. That is a very intrusive requirement because classes can only inherit from one other class. Requiring that a class implement an interface, on the other hand, is not intrusive because classes can implement more than one interface.

  • RELEVANCY SCORE 3.54

    DB:3.54:Are The Methods In Java Api Predefined px


    hey all, do any body know the inner structure of java api . Are the methods of interfaces and abstract
    classes in java api predefined.please let me know

    DB:3.54:Are The Methods In Java Api Predefined px

    If there is an abstract class or interface in the API, then you can't use it at all unless there's a concrete implementation somewhere in the classpath. How that is found depends.... You could new a DefaultMultableTreeNode to get a MutableTreeNode or TreeNode object, or you could use a factory type method like Calendar.getInstance() to get a Calendar object, which would probably be a GregorianCalendar in most locales. Some of those implementations could use JNI, as mentioned already, otherwise they are implemented in Java.

  • RELEVANCY SCORE 3.53

    DB:3.53:Scenarios For Abstract Classes And Interfaces jm


    Would please tell me the exact scenarios when we should use abstract classes and interfaces.

    this question disturbing me for a long time....dont think its a simple basic question, it seems to be easy and to satisy any person by explaining it's litttle bit complicated....

    thanks

    DB:3.53:Scenarios For Abstract Classes And Interfaces jm

    In short: always prefer interfaces for reference types, and always prefer interfaces versus fully abstract classes. If the class has some implementation, you have no choice anyway.

  • RELEVANCY SCORE 3.52

    DB:3.52:Abstract Classes And Interfaces ak


    Can anyone help me in understanding the concepts of Abstract Classes And Interfaces? What is the real application in Java Programming?

    I shall be thankful if anyone can answer this question by supplying a simple sample code that solves my problem.

    Thanks.

    DB:3.52:Abstract Classes And Interfaces ak

    Hi !

    Just a few words about an Abstract classes:
    Abstract means - INCOMPLETE, it means that some methods of this class are not realized these methodes called Abstract because it does nothing.
    You can use the abstract classes as a common classes or parent classes for descendants. And descendants itself may or may not realize the abstract methods each in defferent manners. For example:
    You have a common abstract class called Shape which is have an abstract method draw(), and You can now make for example two descendants Poly and Triangle.

    Here is a couple of code:

    abstract class Shape{
    ...
    abstract protected void draw(Graphics g);

    public void paint(Graphics g){
    .....
    draw(g);
    ......
    }
    ...
    }

    // The descendant of Shape
    class Poly extends Shape{
    .....
    protected void draw(Graphics g){
    .......
    // Here is the realization of this method specific for Polygons
    }
    .....
    }

    // Another descendant of Shape
    class Triangle extends Shape{
    .....
    protected void draw(Graphics g){
    .......
    // Here is the realization of this method specific for Triangles
    }
    .....
    }
    Remember that the descendant classes are inherit all the methods and properties of a parent class, this means that you can freely use them.
    It is called Inheritance.
    So the Abstract classes is for inheritance.

    Now about an interfaces:

    Interface it is just a declaration of methods and properties without realization. It means that some class can implement one or more interfaces, it is like a mask in a theatre, and class here is an actor with a different masks depending on situation. Also it is like connectors to methods. Another class can call the methods of the first class via the casting mechanizm to Interface.

    for example:
    public interface One{
    public int one();
    }

    // This class implements Interface One
    public class Foo implements One{
    ...
    public int one(){
    int res;
    ....
    // some calculations on res
    ....
    return res;
    }
    ...
    }

    //This class calls the methods of Interface one
    public class Doo{
    Vector objs;// here is the different objects which is implements interface One

    public void addObj(Object o){
    objs.add(o);
    }
    ....
    public void somethingToDo(){
    One o;
    int res;
    for(int i=0;iobjs.size();i++){
    o = (One)objs.elementAt(i);
    res+=o.one();
    }
    .....
    // something else with res
    System.out.println(res);
    }
    ....

    }

    public class Three{
    ....
    Doo doo = new Doo(); // something like that
    .....
    public void do(){
    Foo foo = new Foo();
    doo.add(foo);
    }
    ......
    private void show(){
    doo.somethingToDo();
    }
    ......
    }
    In this example class Doo know nothing about the class Foo. But it knows that the objects in his internal vector objs implements interface One.
    So he can freely cast it to that interface and call its method public int one().

    All of this called Polymorphism. It is like a Genie from the lamp. "Whom do you want me to be, master?"

    I hope this helps You to understand.

    Regards, Alex

  • RELEVANCY SCORE 3.51

    DB:3.51:Extending Abstract Classes az


    When I try to compile my code, I get the error message stating my classes are not abstract and do not override an abstract method in the parent class. I don't want to make the other classes abstract, so how am I supposed to extend the abstract class to ensure my code compiles?

    DB:3.51:Extending Abstract Classes az

    Wow, maybe I'm a little better than I thought. Thanks to both of you for your help. Very appreciated.

  • RELEVANCY SCORE 3.49

    DB:3.49:Re: Inner Classes/Interfaces fa


    Look at java.util.Map and java.util.Map.Entry -

    interfaces can have inner interfaces!

  • RELEVANCY SCORE 3.49

    DB:3.49: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.49: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.49

    DB:3.49:Abstract Classes, Interfaces - When, Why? 13


    Hi,
    I was facing a question in an interview that why interfaces or abstract classes are needed? when will you go with them?
    why cannt we just create simple classes and achieve the functionality?

    Can anyone help?

    DB:3.49:Abstract Classes, Interfaces - When, Why? 13

    Well Excuuuuuuuuuuuuuuuuuuuse us;
    People are bending over backward to help you and you can't even say thanks for any of the responders by voting them a point or two.

    Benefits of interface 1) Well defined contracts 2) Doesn't care about implementation

    Benefits of Abstract Class 1) Abstracts commonality as a base class 2) Auto inherited properties, fields and methods, 3) Can define implementation.

    Now is that the right answer?

    JP Cowboy Coders Unite!

  • RELEVANCY SCORE 3.48

    DB:3.48:Plz Answer Anyone To My Question cf


    when we will go for abstract classes and when we will implement interfaces...plz give me the suitable answer to my question with example

  • RELEVANCY SCORE 3.48

    DB:3.48:Default Access Types 1a


    Q2)
    What is the default access type (public / privated / protected ...etc)
    of the following?
    class
    interfaces
    abstract classes
    variables
    methods

    abstract methods
    properties
    indexers

    DB:3.48:Default Access Types 1a

    Hi,
    Yes my post didn't considered all scenario that you all explained.
    e.g., for variable i assumed to be a class member, not inside a method, because there is no sense in talking about access modifier of a variable inside a method(all members defined in a method will always be in it's own scope, so no question of private/public).
    Hence i said default access modifier of variable is private.
    If you take all scenarios into considerations obviously my post may seem having some wrong information.
    similarly for a class or interface why you are thinking about it's members? It is about access specifier of a class or interface itself (which is internal) not for it's members.
    One thing I went wrong was access specifier of class/interface/abstract class which is internal not protected internal.

    One good question is equivalent to ten best answers.

  • RELEVANCY SCORE 3.48

    DB:3.48: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.48: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.48

    DB:3.48:What Is An Interface &Amp; Abstract Class ? zm


    hi ,
    i am new to java,
    pls give the answer for this question,

    what is an interface abstract class ?
    why we go for interfaces and abstract classes?

  • RELEVANCY SCORE 3.48

    DB:3.48:Interface And Abstract Classes d9


    i am not clear about abstract class and interfaces. i mean what's the point in making then when we have empty methods in them we can't call their construtors.

    we can inherit from the method of interface so what's the point in making them at all.

    why should we use abstract classes any way. why not simple class to get the same functionality rather better.

  • RELEVANCY SCORE 3.48

    DB:3.48:Regarding The Abstract And Interface km


    hai,
    I am new to java programming

    I want to difference between abstract interface,interface and abstract class

    public abstract interface Test{}

    public interface Test{}

    public abstract class Test{}

    which kind of situations use the above interfaces and abstract classes

    It would be helpfull if explain with example....

    Thanks

    DB:3.48:Regarding The Abstract And Interface km

    shashikumar, please don't multipost and don't use the browser's back button to edit your post. This creates multiple posts. I've removed the other thread you started a minute after this one.

    db

  • RELEVANCY SCORE 3.48

    DB:3.48:Need Assistance To Know How To Map An Interface In Web Service(Wsdd) zd


    Hi,

    I am writing a Web Service which has a Bean Class, this Bean Class implements a lot of interface and other Bean Classes extends Abstract Class.

    I want to know is it possible in Axis to map these Interfaces and Abstract Class in the WSDD file. I am Mapping the Bean Class but doesnt have any idea about interfaces and abstract classes.

    DB:3.48:Need Assistance To Know How To Map An Interface In Web Service(Wsdd) zd

    Hi,

    I am writing a Web Service which has a Bean Class, this Bean Class implements a lot of interface and other Bean Classes extends Abstract Class.

    I want to know is it possible in Axis to map these Interfaces and Abstract Class in the WSDD file. I am Mapping the Bean Class but doesnt have any idea about interfaces and abstract classes.