• RELEVANCY SCORE 5.62

    DB:5.62: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.62: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.14

    DB:5.14: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:5.14: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 4.96

    DB:4.96: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 4.79

    DB:4.79:Abstract Class Question x1


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

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

    DB:4.79: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:4.79: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 4.55

    DB:4.55:Re: Abstract Classes Vs Private Constructor j3


    compSciUndergrad wrote:
    ...
    What are the benefits of making a class abstract ...?Hi compSciUndergrad,

    Here's a talkative example :
    abstract class Pet {
    abstract void speak();
    }

    public class Cat extends Pet {
    @Override
    void speak() {
    System.out.println("Meow !");
    }
    }

    public class Dog extends Pet {
    @Override
    void speak() {
    System.out.println("Woof !");
    }
    }

    public class Test {
    public static void main(String[] args) {
    Pet[] pets = new Pet[2];
    pets[0] = new Cat();
    pets[1] = new Dog();
    for (Pet p : pets) {
    p.speak();
    }
    }
    }

  • RELEVANCY SCORE 4.42

    DB:4.42:Abstract Classes Vs Adapter Classes z7


    Hi,
    If we need to make use of an adapter class, why do need the interface -- won't abstract classes serve the same purpose???
    I mean if we are going to extend the adapter class and then override the method we want to implement -- why the need for the interface at all -- wouldn't it be simpler if we just used an abstract class and override the function we want to implement????
    Thanx,
    TheJavaKid

    DB:4.42:Abstract Classes Vs Adapter Classes z7

    Every once in a while, you'll want to make a WindowListener (for example) that also extends another class. You couldn't do this if WindowListener weren't an interface.

  • RELEVANCY SCORE 4.38

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

    DB:4.27: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 4.23

    DB:4.23: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:4.23: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 4.13

    DB:4.13:When Should I Use Abstract Class And When I Should I Interfaces x8


    when should we use abstract classes over interface or vice versa;i am getting this question regulary;how should i give proper answer.

    whatever methods we define in abstract class same thing we can do in interfaces;

    so what we can achieve with abstract class;

    with regds
    chaitanya

    DB:4.13:When Should I Use Abstract Class And When I Should I Interfaces x8

    You can implement multiple interfaces. You can only inherit from one abstract class.

    Abstract classes can implement some methods (and define others abstract).

    Abstract classes can have fields that get inherited, interfaces can't.

  • RELEVANCY SCORE 4.12

    DB:4.12: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.12: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.09

    DB:4.09: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:4.09: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.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.89

    DB:3.89:Stronger Postconditions For Interfaces That Implement Interfaces With Weaker Postconditions - How? fp


    Let's say we're writing some library e.g. for drawing on the screen, and to allow our clients to communicate with our library, we're also writing an API, which contains, among other things, some interfaces describing what data should clients pass to our
    library methods, callback API etc. It seems that not only Code Contracts perfectly fit there, but that it might be the primary reason Code Contracts were designed at all.
    The interfaces, of course, do not contain any data, so there is no need to turn these into abstract classes. Additionally, the client will possibly want to derive their classes from some another classes (e.g. from their SuperDataEntity), so we even should
    avoid turning the interfaces into abstract classes.
    However, our data model is so enterprisey, that we cannot live without inheritance in interfaces. So, in the end, we get something like that in our base library:

    [ContractClass(typeof(ContractShape))]
    interface IShape
    {
    int numberOfVertices
    {
    get;
    }
    }

    [ContractClassFor(typeof(IShape))]
    abstract class ContractShape : IShape
    {

    #region IShape Members

    public int numberOfVertices
    {
    get {
    Contract.Ensures(Contract.Resultint() 0);
    throw new NotImplementedException();
    }
    }

    #endregion
    }

    [ContractClass(typeof(ContractTriangle))]
    interface ITriangle : IShape {

    bool amIRight {
    get;
    }

    }

    [ContractClassFor(typeof(ITriangle))]
    abstract class ContractTriangle : ITriangle {

    #region ITriangle Members

    public bool amIRight
    {
    get { throw new NotImplementedException(); }
    }

    #endregion

    #region IShape Members

    public int numberOfVertices
    {
    get {
    Contract.Ensures(Contract.Resultint() == 3);
    throw new NotImplementedException();
    }
    }

    #endregion
    }

    DB:3.89:Stronger Postconditions For Interfaces That Implement Interfaces With Weaker Postconditions - How? fp

    When you do interface inheritance, there are no new methods for the inherited ones. IShape.numberOfVertices is the only method that exists. There is no IPolygon.numberOfVertices method at all (look at the IL). That is why you cannot add contracts in interfaces
    to base interface methods.
    In abstract classes/implementations, it is different as the new methods actually exist and thus you can add contracts there.
    Cheers, -MaF (Manuel Fahndrich)

  • RELEVANCY SCORE 3.89

    DB:3.89:Protected Constructor And Factory Classes For Interfaces And Abstract Class mp


    Hi, In J2SE specification, many protected constructors are defined in abstract class with below sentence

    'Default constructor is protected on purpose'

    I use private constructor very often to disallow instanciate of classes.

    Is it same purpose? Is the reason defined as protected that specification does not show private method?

    Another question is,

    There are many factory classes also in J2SE.
    The factory classes usally has a static method to create certain instance
    like newInstance(). But in many case, the instance created by factory is
    type of interfaces or abstract classes, for example JMXConnector
    JMXConnectorFactory . As you know implementation classes of interfaces or abstract classes can have constructor, thus
    factory class can't guarantee all instances are created by factory class.
    Can anyone tell me what is reason to define factory class for interfaces and abstract classes?

    DB:3.89:Protected Constructor And Factory Classes For Interfaces And Abstract Class mp

    So nobody has to know what the implementation class even is, and
    they can't find out easily whether it has extra public methods for its
    own convenience.
    This is Object Oriented Programming 101 really. I agree the good thing when using factory for interfaces.
    What I really want to do is, for certain interface A, I want all
    its sub classes are created through a Factory class to register
    all instances of the interface to manage in centralized location.
    For my case, factory class can't guarantee it, right? Do you know
    any way to guarantee it ?

    I want you ask from a point of specification writer view.

  • RELEVANCY SCORE 3.81

    DB:3.81: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.79

    DB:3.79: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.79: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.79

    DB:3.79:Abstract Classes Interface ? kd


    Hello

    I wonder if anyone could help me to stright out my big questionmark regarding Abstract classes and Interfaces by answering following questions.

    1) When and why should I use Abstract classes, an real life example would be very appreciated. I have been programming for a while but I have never created an Abstract class.....

    2) Whats the difference in using Abstract classes and an interface when both of them explains whats are needed. Is an interface just an design pattern that points out which methods that are required so this particulare class should be working or correctly or?

    Thanks!

    Regards /D_S

    DB:3.79:Abstract Classes Interface ? kd

    Please search the forum or google. This has been asked, and answered about 8928911 times before.

    Kaj

  • RELEVANCY SCORE 3.79

    DB:3.79:Refer To Objects By An Interface cz


    This was always something i really liked doing.
    It always seemed like smarter design to me but i never really
    talked to anyone about it.

    Recently i was trying to decide whether an interface or abstract class
    was a better decision for a project i was working on and i read this:
    http://mindprod.com/jgloss/interfacevsabstract.html

    which said of Interfaces vs Abstract Classes:

    Interface
    Slow, requires extra indirection to find the corresponding method in the actual class. Modern JVMs are discovering ways to reduce this speed penalty.

    Abstract Class
    Fast

    In a recent post i was happy to see that yawmark posted a link to:

    Item #34 - Refer to objects by their interfaces
    -- Chapter 7, Effective Java, by Joshua Bloch
    http://www.informit.com/isapi/product_id~%7B7DE69993-3EF5-4354-9E10-9F8A535909F1%7D/content/images/0201310058/samplechapter/blochch7.pdf

    It was nice to hear someone support what i had suspected but
    is it true that this is a "slow" practice?

    DB:3.79:Refer To Objects By An Interface cz

    For any practical definition of "slow," no.

    And as a further matter of practicality, it's pretty much unpredictable as to what difference either way will make, as evidenced by the following test. Sometimes "interface access" is faster, sometimes it's slower, and sometimes it's the same. This is likely due to factors unrelated to the actual process of resolving the method. As I see it, the primary concern is that of design; performance is largely irrelevant.

    class TestRunner {
    static final int TEST_RUNS = 5;

    public static void main(String[] args) throws Exception {
    Bar b = new Bar();
    Test[] tests = {
    new ImplAccessTest(b),
    new IntfAccessTest(b)
    };
    for (int i = 0; i TEST_RUNS; i++) {
    for (Test t : tests) {
    t.execute();
    clean();
    }
    System.out.println("\n ------------------------ \n");
    }
    }

    static void clean() {
    for (int i = 0; i 3; i++) System.gc();
    System.runFinalization();
    try { Thread.sleep(100); } catch (Exception e) { }
    }


    }

    interface Test {
    void execute() throws Exception ;
    }

    abstract class AbstractTest implements Test {

    static final int ITERATIONS = 10000000;

    abstract void doTest() throws Exception;

    public void execute() throws Exception {
    long start = System.currentTimeMillis();
    for (int i = 0; i ITERATIONS; i++) {
    doTest();
    }
    long finish = System.currentTimeMillis();
    long elapsed = finish - start;
    printResults(elapsed);
    }

    private void printResults(long elapsed) {
    System.out.printf("%s (%d iterations) - total elapsed: %6d millis, average: %.6f millis\n",
    getClass().getName(), ITERATIONS, elapsed, (double) elapsed / ITERATIONS);
    }
    }

    class ImplAccessTest extends AbstractTest {

    Bar b;

    ImplAccessTest(Bar b) {
    this.b = b;
    }

    void doTest() {
    b.method();
    }
    }

    class IntfAccessTest extends AbstractTest {
    Foo f;

    IntfAccessTest(Foo f) {
    this.f = f;
    }

    void doTest() {
    f.method();
    }
    }

    interface Foo {
    void method();
    }

    class Bar implements Foo {
    public void method() { /* call me */ }
    }Results (XP Pro, 3 GHz, 1.5 GB, JDK 5):
    ImplAccessTest (10000000 iterations) - total elapsed: 141 millis, average: 0.000014 millis
    IntfAccessTest (10000000 iterations) - total elapsed: 142 millis, average: 0.000014 millis

    ------------------------

    ImplAccessTest (10000000 iterations) - total elapsed: 157 millis, average: 0.000016 millis
    IntfAccessTest (10000000 iterations) - total elapsed: 141 millis, average: 0.000014 millis

    ------------------------

    ImplAccessTest (10000000 iterations) - total elapsed: 157 millis, average: 0.000016 millis
    IntfAccessTest (10000000 iterations) - total elapsed: 126 millis, average: 0.000013 millis

    ------------------------

    ImplAccessTest (10000000 iterations) - total elapsed: 142 millis, average: 0.000014 millis
    IntfAccessTest (10000000 iterations) - total elapsed: 189 millis, average: 0.000019 millis

    ------------------------

    ImplAccessTest (10000000 iterations) - total elapsed: 142 millis, average: 0.000014 millis
    IntfAccessTest (10000000 iterations) - total elapsed: 142 millis, average: 0.000014 millis

    ------------------------ With regards to the bytecode, the difference between the tests is the use of invokevirtual versus invokeinterface.

    ~

  • RELEVANCY SCORE 3.78

    DB:3.78:Why Cant Abstract Attribute Classes Be Generic? 17


    I understand why concrete classes deriving from Attribute cannot be generic, but why aren't abstract generic classes allowed. For example:abstract class AbstractAttributeT : Attribute{    T thing;}class ConcreteAttribute : AbstractAttributestring{}I think the above ought to be entirely safe, but it won't compile. Is there a good reason this isn't allowed, or is it just because the spec says so?P.S. I'm trying to implement some generic interfaces and it's very difficult without generic abstract Attribute classes.

    DB:3.78:Why Cant Abstract Attribute Classes Be Generic? 17

    Hi,
     
    Yeah I think it because you can't have generic attributes. Could be because attributes are compiled into metadata which can be referenced from other .NET languages that don't support generics. Thats just a guess but I bet it has something to do with it, kind of a shame because that would be pretty cool if you could do that.
     
    http://weblogs.asp.net/whaggard/archive/2004/10/12/241476.aspx

  • RELEVANCY SCORE 3.78

    DB:3.78:Using Vs 2010 For Code Analysis ap



    I am using VSTS 2010 Ultilmate and not awareas howtofind the following options. If VS 2010 doesnt have it, can you pls suggest other tools which can help me in
    finding these details...

    ·
    Duplication of code

    ·
    % Commented Code

    ·
    Number of Parameters, Number of Variables, Number of Overloaded methods.

    ·
    Cohesion and Coupling

    o
    No of Abstract Classes or Interfaces referred

    o
    No of Interfaces Implemented.

    o
    Cohesion of Methods

    DB:3.78:Using Vs 2010 For Code Analysis ap

    Duplication of Code is coming in Visual Studio 11, see this article.
    % of commented code is not available
    Number of Parameters, variables, overloads, there are a few CA rules that warn you if you really go overboard with these, but there is no simple report you can open.
    Cohesion and Coupling, coupling is part of the Visual Studio 10 Ultimate edition and can be found under the
    Analyze, Code Metrics menu., cohesion isn't I believe.
    No of abstract classes or interfaces, not there, there is a CA rule which will flag a warning for the number of dependencies (be it normal, abstract or interface) again when you really go overboard. No simple report you can open.
    No of interfaced implemented, not there
    Cohesion of methods, again part of the Code Metrics feature.
    If this is veryimportantto you, then consider investing in
    Visual NDepend, it gives you all of these, plus a lot more. It is, however, notoriously hard to learn.My blog: blog.jessehouwing.nl

  • RELEVANCY SCORE 3.70

    DB:3.70:Abstract Classes And Interfaces 1k


    What is the difference?

    DB:3.70:Abstract Classes And Interfaces 1k


    Hi Bobby1233

    1.
    Abstract class

    Abstract class is a special class, only cant be instantiate, except that, it has all the features a normal class has. A abstract class could contain abstract
    method and this feature doesnt contained by the normal class. If a class derived from an abstract class, it must override the abstract method which declared in the abstract class. An abstract class can also derived from another abstract class, it could
    override the super classs abstract method or not, if it doesnt override, the derived class must override it.

    2.
    Interface

    The interface couldnt be instantiate, it could contain method declaration, property, indexer and event, they all declared public, a class could inherited
    from many interfaces.

    3.
    The difference

    A class derived from an abstract class should override the virtual method which declared in the super class, but if a class derived from an interface, it must
    realize all the members the interface declared. A class only can derived from one abstract class but it can derived from many interfaces. An abstract is a classs abstraction, but the interface is a behavior standard.

    Theres an analogy can help you understand easily:

    A plane can fly and a bird also can fly, they all inherited a fly interface; A helicopter belong to plane abstract class and a pigeon belong to a
    bird abstract class.

    I wish it could help you!

    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • RELEVANCY SCORE 3.68

    DB:3.68:Why R The Io Classes In Java Abstract 71


    hi
    i am pretty new to java programming can any body say why the java.io classes
    are abstract.is this because if they were interfaces they should implement all the methods in that interface implemented if so when we made them abstract then we need not overriding all the abstract methods(like close).this is puzzling me so plz can any one say bt this.a quicker response is appriciated
    thanx in advance
    bhushan.

  • RELEVANCY SCORE 3.67

    DB:3.67:Interfaces Vs Abstract Classes kp


    hi,
    i have some kind of general idea about interfaces and abstract classes.but what are the situations that are most suitable for use interfaces and abstract classes..if u have any idea pls help me
    thanx and best regards,
    Kelum

    DB:3.67:Interfaces Vs Abstract Classes kp

    hi all,
    thanx for u all for the given support..now i have an idea abbt how to use those
    thanx and best regards,
    kelum

  • RELEVANCY SCORE 3.66

    DB:3.66: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.66: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.64

    DB:3.64: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:3.64: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 3.61

    DB:3.61: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.61: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.59

    DB:3.59: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.59: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.57

    DB:3.57: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:3.57: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 3.56

    DB:3.56:Re: Interface Vs. Abstract Classes aa


    Thanks samue

    One more thing i wish to know, Is it possible to have classes inside interface and if yes, then whats the need of that

    DB:3.56:Re: Interface Vs. Abstract Classes aa

    HI jverd

    Can you explain the answer of my questions clearly

    Thanks

  • RELEVANCY SCORE 3.56

    DB:3.56:Abstract Classes Vs. Interfaces s3


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

    DB:3.56: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.55

    DB:3.55: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.55: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.51

    DB:3.51: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.51: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.50

    DB:3.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:3.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 3.50

    DB:3.50:Abstract Classes Vs. Interfaces 3d


    An abstract method can only be implemented by a virtual method, while this is not necessarily so for a method declared in an interface.  Why must it be this way for abstract methods, and if so why is it not this way for methods declared in interfaces?
     
    Thanks!

    DB:3.50:Abstract Classes Vs. Interfaces 3d

    That was very informative, thank you.
     

  • RELEVANCY SCORE 3.49

    DB:3.49:Re: Interfaces And Abstract Classes 1f


    Does this mean that the classes on which i implement those interfaces can be extended and reused further

  • RELEVANCY SCORE 3.49

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

    DB:3.49: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:3.49: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 3.46

    DB:3.46: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.46: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.42

    DB:3.42: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.42: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.42

    DB:3.42:Abstract Classes And Interfaces 8s


    Why would you use these? Why not make a concrete class and extend them? I see why JAVA doesn't use mutiple inheritance but I don't see how allowing interfaces correctes that, after all what happens if two interfaces implemented by one class have two fully defined methods with the same signature but differant outputs?

    I tryed googleing this but just got articles on when to use Abstract over interface and interface over abstract, which should have helped some but it didn't.

    Can someone explain or post a link for a good example.

    DB:3.42:Abstract Classes And Interfaces 8s

    Okay thank you all. I check those out once I get home (I don't have the src.zip, or even JAVA on this computer (It's the schools)).

  • RELEVANCY SCORE 3.42

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

    DB:3.42:Interfaces Vs. Abstract Classes ps


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

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

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

    DB:3.42:Interfaces Vs. Abstract Classes ps

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

    cheers

    -tamoghna

  • RELEVANCY SCORE 3.42

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


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

    DB:3.42: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.42

    DB:3.42:Abstract Classes &Amp; Interfaces xp


    In the API we have an interface namely:Set
    which is implemented by an abstract class AbstractSet.

    Class HashSet extends AbstractSet implements Set.

    Now What is need for HashSet class to implement a Set interface when it is already extending from AbstractSet class that inturn implements Set interface.

    DB:3.42:Abstract Classes &Amp; Interfaces xp

    This is probably an case of the folks at Sun refactoring their code and just missing one cleanup detail. The initial implementation of HashSet probably did not have a subclass. Then when they started to implement TreeSet, they realized that there was common functionality that they could reuse.

    As the previous writer mentioned and you observed, there is no advantage or reason for HashSet to implement Set, it's probably just a harmless oversight.

  • RELEVANCY SCORE 3.41

    DB:3.41: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:3.41: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 3.40

    DB:3.40: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:3.40: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 3.37

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

    DB:3.37: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.36

    DB:3.36:Abstract Class And Interfaces jf


    Hi,

    In which senarios, we can choose abstract class and interfaces

    Thanks

    DB:3.36:Abstract Class And Interfaces jf

    Hi,

    The most important scenario of deciding when to use Abstract Class or an Interface comes by trying to establish an IS-A relationship (abstract class) or CAN-DO relationship (Interface) is found between the related objects.

    1. e.g.
    A "Manager" IS AN "Employee" and a "SoftwareEngineer" IS ALSO AN "Employee"
    so for this relationship we can create an "Employee" Abstract class and the other classes "Manager" and "SoftwareEngineer" should derive from it and may provide their own implementations...........

    2. e.g.
    There will an annual appraisal for all types of Employees in an Organization. so, all employees must establish a certain kind of contract to fulfill for Appraisal which is done by an "IAppraisal" interface which has 2 methods - viz. a). public void IncreaseGrade();
    b). public void IncreaseSalary(double percentage);

    Hope this clarifies the scenario.

    Other aspects to decide are Versioning and Ease of Use between the 2.

    For more: pl. refer Applied .Net Framework book by Jeffry Richter

  • RELEVANCY SCORE 3.36

    DB:3.36: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:3.36:Abstract Classes Vs Interfaces ma

    hi,
    thanx a lot for your help

    regards
    sundar

  • RELEVANCY SCORE 3.36

    DB:3.36:Java Interfaces And Abstract Classed fc


    what is the difference between interface and abstract class?

    DB:3.36:Java Interfaces And Abstract Classed fc

    I suggest you try writing some code and see.

  • RELEVANCY SCORE 3.36

    DB:3.36: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.36: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.36

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

    DB:3.36:What Is The Actual Difference Between Interfaces &Amp; Abstract Classes..? 73


    Hi Friends..!

    Please let me know what is the actual difference between Interfaces and Abstract Classes. All we can do in Abstract classes(ofcourse, except method definitions), is still possible to do in Interfaces. Then, why the concept of Abstract classes..?

    In which situation, we need Interfaces rather than Abstract classes and Vice-Versa..?

    Regards,
    k.suresh

  • RELEVANCY SCORE 3.35

    DB:3.35: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.35: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.35

    DB:3.35: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.29

    DB:3.29: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:3.29: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 3.25

    DB:3.25:Re: Inheritance Vs Interfaces 9j


    Ok...my mistake...got too many questions :o)

    So basically, you go for interfaces when you want to share empty classes....and inheritance when you want to modify class type ...

    =|

    DB:3.25:Re: Inheritance Vs Interfaces 9j

    The other place where interfaces rock is when you want to define a "interface contract" which others implement.

    JDBC is good example. The set of java.jdbc.#42; interfaces is defined (I presume) by "an industry consortium", and then vendor writes there own JDBC driver, which "conforms to the standard interface". The result is that I can treat a MySQL database (more or less) the same as an Oracle database within my application, which means that I'm no longer "locked in" to Oracle's RDBC, so if they charge too much, or otherwise give me the Sierra Hotel India Tangos, I can (theoretically at least) dump them like a hot solanum tuberosum.

    Cheers. Keith.

  • RELEVANCY SCORE 3.25

    DB:3.25: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.25: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.

  • RELEVANCY SCORE 3.25

    DB:3.25:Re: Interface Vs Abstract Class 1d


    Abstract classes have the significant advantage that you don't have to change each and every implementation if you add a new method with a sensible default implementation.

    DB:3.25:Re: Interface Vs Abstract Class 1d

    You cannot tighten a screw with a hammer. You break
    the threading, and it will remain loose.But it's very hard to hit broken things repeatedly in a satisfying manner with a screwdriver in such a way that the thing in question is not recognizeable as what it was to begin with. Granted, it's possible but rather hard to do with a screwdriver ;-)

  • RELEVANCY SCORE 3.25

    DB:3.25:Interfaces And Abstract Classes fk


    hi,

    Can anyone help me regarding the difference between interfaces and abstract classes. What is the advantage of interface over abstract classes and viceversa. Obout the possibities of multple inheritance I know. I found allmost all people are talking some external answers.
    Why an abstract class cant we do it with concrete class.
    regards,

    Jayaprasad Viswanathan

    DB:3.25:Interfaces And Abstract Classes fk

    Abstarct class can never be instantiated. Same as interfaces.

    Can be
    subclassed.Same as interfaces.

  • RELEVANCY SCORE 3.25

    DB:3.25:Abstract Classes And Interfaces kp


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

    DB:3.25:Abstract Classes And Interfaces kp

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

  • RELEVANCY SCORE 3.25

    DB:3.25: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.25: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.25

    DB:3.25:Re: Abstract Class &Amp; Interface xp


    i posted a part of a pdf file for understanding about abstract classes and interfaces. trust me read it thoroughly and once you are finished you will say Ah.. that is why we use interfaces and abstract methods. This will give you a brief description on java inheritance, polymorphism and abstraction and interfaces.

    Good Luck

    DB:3.25:Re: Abstract Class &Amp; Interface xp

    Hai Ram! It is the batameeze leading the the
    batameeze!You mean budding budtameezee? ;)Yes budding. As in fungus that reproduce by budding. :-)

  • RELEVANCY SCORE 3.25

    DB:3.25: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:3.25: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 3.24

    DB:3.24:Abstract Classes And Interfaces? px


    im confuse with the difference of this two, as I read two different e-books, i found out that these two things, the abstract interface classes have both methods that doesn't have a body and ends with a semicolon... can anyone differentiate more elaborately the use of these two classes?,

    DB:3.24:Abstract Classes And Interfaces? px

    TimSparq wrote:
    I like this article:

    http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.htmlnice article dude..thanks

  • RELEVANCY SCORE 3.23

    DB:3.23:Abstract Interfaces 7m



    Hello XIers

    In an Integration Process, can I only use abstract interfaces (Can't I use inbound/outbound interfaces?) ???

    thanks

    Julio

    DB:3.23:Abstract Interfaces 7m


    bHi Julio,/b

    BPM understands only abstract interface. So you will have to define a abstract interface for each message going into BPM and inbound interface going out of BPM.

    So for example if you have a bpm scenario where in data is passed from file adapter to BPM to file adapter. If your outbound message is bVendor_Outbound/b you have to create a new message interface bVendor_Abstract/b. This message will pass through BPM and undergo transformation to become bVendor_Abstract_after_Mapping/b. This message again can't be undertstood by communication channels and hence needs to be mapped to a similar message inbound interface structure. So the final message outside the BPM would be bVendor_Inbound_after_Mapping/b

    Also you can only declare asynchronous abstarct interface as the container elements. So no synchronous abstract interfaces can be defined as container element.

    bRegards,

    Ashish/b

  • RELEVANCY SCORE 3.23

    DB:3.23: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:3.23: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 3.22

    DB:3.22: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.22: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.22

    DB:3.22: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:3.22: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 3.21

    DB:3.21: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:3.21: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 3.19

    DB:3.19: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:3.19:Basic Java Mcq! d7

    Also, a good site to see...

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

    Regards,
    Sidath.

  • RELEVANCY SCORE 3.17

    DB:3.17:Re: What Good Are Interfaces j1


    Multiple inheritance in java is implemented using interface, You can't inherit
    more than one classes(using extends ). but u can inherit many interfaces(using implements ). In interfaces all the methods are abstract.

    DB:3.17:Re: What Good Are Interfaces j1

    yawmark's explanation is perfect.Indeed. But just because I like the sound of my own voice (internetally speaking) allow me to provide an analogy.

    When someone tells you what a car is--you make it go by pressing here, make it stop by pressing there, make it turn by turning the wheel, etc.--you know how to drive any car (more or less--not a perfect analogy, I know, but roll with it). You don't care if they strip off every logo and nameplate. You know that this thing IS-A car, and therefore, you can make it go by pressing here, etc.

    An interface is like the description of what every Car has in common. When you take driver's ed, the class is giving you the Car interface. Later, when you get a concrete Car instance, you don't care what kind of Car it is--you know what it can do and how to make it do it because of the interface. You get in the Car, turn the key, put it in gear, press the accelerator, and so on. Simply referring to it as a Car is enough to tell you that you can do those things and what the results will be.

  • RELEVANCY SCORE 3.17

    DB:3.17: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.17: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.17

    DB:3.17:Interface j1


    Hi ,

    Can any one please let me know why interfaces and abstract classes don't have objects?

    What is the uses of delegation in java?

    My e-mail id is: sankar.brahma@gmail.com

    Regards
    Sankar Brahma

    DB:3.17:Interface j1

    Interfaces and abstract classes cannot be instantiated because their implementation is marked not to be complete. As simple as that. You'll need to subclass/implement them to have a class that allows instantiation.

    As for delegation: same as in any other language. It helps avoiding the use of inheritance where it's not appropriate.

  • RELEVANCY SCORE 3.17

    DB:3.17:Help With Interfaces / Abstract Classes Please cp


    Hi all, I was wondering if I was able to get an interface or an abstract class to force the class that interfaces it to create an instance of something? For instance:
    public class A : IMyInterface
    {
    }

    public class B
    {
    }

    public interface IMyInterface
    {
    //I want hear to force any class that interfaces me to create an
    //instance of class B.
    }
    Can I do this? Would I need to use an abstract class to do this as an Interface can't have implementation... Thanks, Onam.

    DB:3.17:Help With Interfaces / Abstract Classes Please cp

    You can't force the class to create an instance of something in an interface, but you can force the interface to implement a property, ie: public interface IMyInterface {     public B MyBInstance     {         get;     } } public class A : IMyInterface {     // A now needs to provide a property that will return a B, or the compiler will complain } You can do the same thing with an abstract base class.  The difference here is that you can put the logic of creating and returning the B property directly into the base class, so it's not duplicated in every class that implements it. However, I would recommend thinking about this slightly differently - If A (and all other types implementing MyInterface) is-a type of MyInterface, then I would make MyInterface an abstract class. If A acts-as or acts-like or can perform as a MyInterface, then I would make MyInterface an interface. Reed Copsey, Jr. - http://reedcopsey.com

  • RELEVANCY SCORE 3.16

    DB:3.16: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.16: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.15

    DB:3.15:Api En Imp z7


    Hi,

    I am relative new to Java. I know the syntax and semantics.
    I am interested in J2EE, therefore looking at JSF

    I downloaded JSF from Sun. I got 2 jar files: jsf-api andf jsf-imp

    My question(s):
    - the jsf-api --- to me it appears as a set of interfaces, real classes and abstract classes. Is this the way an java 'api' is 'delivered' generally?
    - jsf-api --- why are there both real classes AND abstract classes in it? (I would say an api just contains specifications (interfaces and abstract classes) and no implementations (=real classes))
    - jsf-imp --- can someone tell me what an implementation really means? Is it required to implement all the abstract classes which are in the api?

    Thanks for your help.

    Regards
    Stephan

    DB:3.15:Api En Imp z7

    Worry about those things after you have learned JSF basics, its design and architecture.
    You will naturally understand them, then.

  • RELEVANCY SCORE 3.15

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

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

    DB:3.15:Re: Does Abstract Class Really Faster Than Interfaces mm


    938864 wrote:
    Abstract class vs interface is common question and I have been hearing from time and time that abstract class are slightly faster than interfaces Please cite a reference to this.

    P.S. You will not notice any difference so who cares.

    DB:3.15:Re: Does Abstract Class Really Faster Than Interfaces mm

    In what respect have I not just answered exactly that question?

  • RELEVANCY SCORE 3.14

    DB:3.14:Pragmatic Review Of Java Interfaces, Abstract Classes Etc. fj


    Hi,

    I have a pretty good idea of all the basics in java programming, but I really want to learn more about how to design/construct high quality programs with a good use of encapsulation, interfaces and so on. Is there a good book which emphazises on these topics?

    Thank you.

    Nicolai

    DB:3.14:Pragmatic Review Of Java Interfaces, Abstract Classes Etc. fj

    Getting experience is probably the best thing, but there are also some good books, e.g. Refactoring Improving the design of existing code by Martin Fowler and Beyond Software Architecture creating and sustaining winning solutions by Luke Hohmann.

    Kaj

  • RELEVANCY SCORE 3.14

    DB:3.14: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.14: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.11

    DB:3.11: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.11: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.11

    DB:3.11:Re: Problems With Abstract And Interfaces xp


    I want to do this:

    One principal abstract class that has two methods
    abstract method 1
    abstract method 2

    two secoundary class
    class A implements method 1
    class B implements method 2

    How can I do this?
    Abstract force me to implemenst all the methods in a
    class?Abstract classes can declare non-abstract methods. Declare
    method1() and method2() in the abstract class, and, neither
    extending class will be required to implement it.

    Also, ==puckstopper. Consider hard if this problem
    is properly solved by inheritance.

    DB:3.11:Re: Problems With Abstract And Interfaces xp

    Then you don't need ten different methods not at all you need one method, and now I think I understand your problem. Inheritance from an abstract class isn't the answer to your problem.

    Consider the following:

    public abstract class SuperClass
    {
    public void methodA()
    {
    // ... Method A functionality
    }

    public void methodB()
    {
    // ... Method A functionality
    }

    public void methodC()
    {
    // ... Method A functionality
    }
    }

    class A extends SuperClass
    {
    public void doStuff()
    {
    methodA() ;
    methodB() ;
    methodC() ;
    }
    }

    class B extends SuperClass
    {
    public void doStuff()
    {
    methodA() ;
    methodB() ;
    methodC() ;
    }
    }You have two classes that inherit from SuperClass and they ALL have access to all of its member functions (methodA() ... methodC()). Since methodA() ... methodC() all do the same thing there's absolutely no point to this at all.

    So, if methodA() ... methodX() all have the same functionality then you only need it in one place [SuperClass] and this is a case where inheritance is the answer that you want.

    Or, if methodA() ... methodX() have different functionality but the same method signature and have NO default behavior then you want an interface which the other developers would implement.

    Or, if methodA() ... methodX() have default behavior but MIGHT be changed by the developer implementing the functionality then a superclass which you would override in the subclass is the correct answer.

    Making sense now?

    PS.

  • RELEVANCY SCORE 3.11

    DB:3.11:Situation To Use Abstract Class 17


    I tried to get knowledge on when to use abstact class and when to use interface. i found some explanaiton in the below path.
    http://msdn.microsoft.com/en-us/library/scsyfw1d(VS.71).aspx
    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.
    So is there any sample code which demostrate this differnece in using? please share with me so that i will get very good clarity on situation to use this. pleaseloving dotnet

    DB:3.11:Situation To Use Abstract Class 17

    There are certain reasons when to use Abstract class and when to go with Interface.

    You can use Abstract class when you want some common operation for all the derived classes followed with the separate implementations of abstract methods. Where as in the case of Interface, only the method declarations are defined and you cannot define any
    common behaviour for all the implementors. Secondly classes can implement multiple interfaces where as in the case of Abstract class if any of the derived class already have some base class inheritance, the abstract class could not derive.

    Ovais

  • RELEVANCY SCORE 3.11

    DB:3.11:Instantiating An Interface ????!!!!!!!!! zp


    as i can recall interfaces are pure abstract classes and agin as i know we can not instantiate abstract classes, then when programming a servlet how do we instantiate the two interfaces: httpServletRequest and httpServletResponse ?
    thank you
    Ali

    DB:3.11:Instantiating An Interface ????!!!!!!!!! zp

    The data (Headers as well as user submitted data) comes to the server from the browser (ex. IE, another Java App, J2ME app, etc).
    The servlet container automatically encapsulates the received data into the HTTPServletRequest object.
    The container also creates a HttpServletResponse Object, which encapsulates "things" required to send information back to the browser, like handle to send response, handle to set cookies, etc

  • RELEVANCY SCORE 3.09

    DB:3.09:Instanceof Operator Question sx


    Can you use instance of (successfully) on interfaces and abstract classes?
    I am confused because if class A implements interface B (or extends abstract class B) it is a type of B but it is not an instance of B, since interfaces/abstract classes cannot be instantiated.

    DB:3.09:Instanceof Operator Question sx

    Sorry, the reason I ask is because on weekdays I have limited internet time so if I ask it here I can work on my projects and get the answer without taking time away from working on my project. Thanks for the answers.

  • RELEVANCY SCORE 3.09

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

    DB:3.09:Re: Comparator Object Instantiation 87


    abillconsl wrote:
    Because Comparator is an interface, not a class. What you did the second time around was flesh it out.More precisely, it's because Comparator is abstract (as are all interfaces), and the anonymous inner class is concrete, with implementations for all of Comparator's abstract methods. The exact same behavior occurs with abstract classes, and for the exact same reason. :-)

    DB:3.09:Re: Comparator Object Instantiation 87

    SquareBox wrote:
    If yes, then why do I have to use an anon class to instantiate the Comparator object? Simple answer is: you don't.
    This works too:static final class SeniorityOrder
    implements ComparatorProduct{
    public SeniorityOrder() {}
    public int compare(Product e1, Product e2) {
    return 1;
    }
    };And then whenever you need one, use 'new SeniorityOrder()'. I hope that isn't your actual comparison method though :-).

    Winston

  • RELEVANCY SCORE 3.09

    DB:3.09:Creating Java Structure For An App. fx


    Hi,

    I have a coffee vending machine application, based on this vending machine features how i can design the framework in java?
    what are the classes, interfaces and abstract classes that will be used here. Please provide some example.

    Thanks.

    DB:3.09:Creating Java Structure For An App. fx

    797836 wrote:
    Hi,

    I have a coffee vending machine application, based on this vending machine features how i can design the framework in java?You don't. You design it in pictures and/or index cards and/or UML and/or something else appropriate for expressing the design. You implement it in Java.

    what are the classes, interfaces and abstract classes that will be used here. Please provide some example.You figure that out as a result of your drawing, notes, etc. They come from the objects and abstract concepts in your higher-level description of the problem and solution.

  • RELEVANCY SCORE 3.07

    DB:3.07: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.07: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.07

    DB:3.07:Interface Vs Abstract Class dm


    I have found the below in the MSDNIf 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. Can we have an example so that we can see the version becomes different after changing the interface and for abstract class running well?Many Thanks.....

    DB:3.07:Interface Vs Abstract Class dm

    Yes, I think the multiple versions in that sentence means exactly that. Because if you do intend to add a concrete method to an already existing class, you're supplying it with a newbehavior, so you're efectively creating a new version of that class. For instance, TimeSpan class (it's not the perfect example for this discussion, because it isn't an abstract class, but it serves the purpose of this example) has been enhanced with a few new features and methods in .NET4, so you can say that you do have a different TimeSpan in .NET3.5 and in .NET4. A new version of TimeSpan.-- Blog: http://geeklyeverafter.blogspot.com/

  • RELEVANCY SCORE 3.07

    DB:3.07: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.07: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.06

    DB:3.06:Re: No Constructors For Interfaces ? ks


    Abstract classes cannot be instantiated directly. But when a subclass is instantiated, any non-overridden implementation within the abstract class is used.

    An interface does not contain any implementation, so what is there for a constructor to do?

    DB:3.06:Re: No Constructors For Interfaces ? ks

    % - I don't know about that (though I suppose it a matter of perspective).

    What you've created there is an instance of an
    anonymous inner class, which implements the interface
    - not an instance of the interface; even though it may
    appear that it is an instance of the interface.You're right, Pinky. Just took a flier and threw it out there.

    Abstract classes can have data members that have to be initialized, and ctors that are called by subclass ctors. Neither of those things are true for interfaces, so you don't need a ctor in that case.

    %

  • RELEVANCY SCORE 3.06

    DB:3.06:Java Oop Question- Interfaces Vs Abstract Classes xm


    In a situation such as the following what would be better OOP practice to do:
    Basically, I want to add a series of panels with different types of information stored on them that can be changed to a TabPane. At the bottom of the screen there would be ok/cancel buttons and the ok button would call the SaveData method on each panel in the pane. Which of the following approaches would be more OOP correct.

    abstract class SavePanel extends JPanel
    {
    public abstract void SaveData(); //method to save information in panel
    public abstract void SetPanel(); //method to add components into itself
    }
    and do:
    class SomeClass extends SavePanel
    {
    bla bla bla
    }
    or
    interface Save
    {
    public void SaveData(); //method to save information in panel
    public void SetPanel(); //method to add components into itself
    }
    and then do:
    class SomeClass extends JPanel implements Save
    {
    bla bla bla
    }

    DB:3.06:Java Oop Question- Interfaces Vs Abstract Classes xm

    If your "SavePanel" will only define those two methods: no gui, default functionality, or anything else like that, an interface would definitely be better.

    Think about this scenario: what if you would some day want to make a text or awt based "save panel"? With abstract super classes you are confined to JPanels.

    But on the other hand, if you'd like some default functionality or GUI...

  • RELEVANCY SCORE 3.05

    DB:3.05:Interfaces And Abstract Classes 8x


    Whats the difference between an interface and an abstract class.

    DB:3.05: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.05

    DB:3.05:Go To Declaration: Get List Of All Declarations, Base Class And Derived Clasess? cz


    Hello,
    Our app makes extensive use of abstract base classes and interfaces. When I try to navigate to a symbol's declaration, I usually am taken to the ABC or interface class. Is there a way to make VS 2010 present a list of options?
    Thanks for any hints...

    DB:3.05:Go To Declaration: Get List Of All Declarations, Base Class And Derived Clasess? cz


    Hi,
    There is only one option to navigate effectively in VisualStudio: use the plugin provided by Resharper. It can do much more and will make you much more productive, but the navigation enhancements are top notch.
    I use it in my day to day work and could not be as productive without it.
    Kind regards,
    Tom de KoningIf a post answers your question, please click Mark As Answer on that post and Mark as Helpful.

  • RELEVANCY SCORE 3.05

    DB:3.05: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.05: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.04

    DB:3.04:Interfaces Vs Abstract Classes Why Even Use Contracts? x1


    Okay, I know there are lots of posts on this. I've read several and they have all helped me get to a reasonable understanding of the differences between both; however, I still can not seem to comprehend
    why anyone would need to enforce a contract for sub classes to follow?

    Correct me if I am wrong abstract classes and interfaces are both basically the same thing with the main difference being a subclass can inherit multiple interfaces while it would not be able to implement more than one abstract class.

    So then this is where I get confused. I know that abstract classes do allow implementation of methods declared virtual which can beoverridden in subclasses. This seems like a very useful technique and I can understand why one would use an abstract
    class for this purpose.

    Now I don't understand why someone would use an abstract class or interface with no type of implementation. Why not just cut those out and define your classes?

    //Not written in VS. Might have typos

    public interface ICanine
    {
    public void Bark();

    }

    public class Beagle : ICanine
    {
    public void Bark()
    {
    //Bark
    }
    }

    public class Wolf : ICanine
    {
    public void Bark()
    {
    //Bark
    }

    }

    //Why not omit the interface and just do this instead?

    public abstract class Canine
    {
    public virtual void Bark()
    {
    //Perform Function A
    }
    }

    public class Beagle
    {
    //Base class Bark Suffices
    }

    public class Wolf
    {
    public override void Bark()
    {
    //Perform function B
    }

    }

    //I just don't see the point in implementing something that has no functionality.

    DB:3.04:Interfaces Vs Abstract Classes Why Even Use Contracts? x1

    Hello,
    Please look into below links you will get your answer.
    1.
    Abstraction Class
    2.InterfaceClass
    3.
    Difference between Interface and Abstraction Class
    Hope it will help for you.
    thanks.