Abstract class Vs  Interface and importance of using

Hi All,
I want to know what is the difference between Abstract class and Interface.
and what is the importance of using them.
Moderator message: please search for available information/documentation.
Edited by: Thomas Zloch on Sep 27, 2011 1:55 PM

Please refer to this thread, already this is discussed in forums
[ABAP Objects.. Abastract & Interface Class;
Thanks
Pavan

Similar Messages

  • Abstract class vs Interface difference

    hi guys
    As such i know the basic difference ,but i want toknow what is the differnece between a interface and an abstract class with all the abstract methods in it.
    thanks a lot
    yash

    ,but i want
    want to know what is the differnece between a
    interface and an abstract class with all the abstract
    methods in it.You can view a class and an interface as being on the opposite extreme ends on a concrete-abstract scale.
    Say you start out with a fully concrete class. Just by adding the abstract keyword the class becomes abstract. You then remove implementation from this abstract class by making more and more methods abstract and finally you also make all methods public. You now basically have an interface. You just replace abstract class with interface and there you are.
    Basically Java wouldn't have to define an interface. The compiler could recognize and mark totally abstract classes as "interfaces" internally. The rules for extension would be that you can only extend one class carrying implementation. All other classes must be totally abstract. But admittedly, the system with declared interfaces is much more convenient for the programmer. You know up front just by looking at it that this "class" must stay totally abstract.

  • How to create the Export Data and Import Data using flat file interface

    Hi,
    Request to let me know based on the requirement below on how to export and import data using flat file interface.....
    Please provide the steps involved for the same.......
    BW/BI - Recovery Process for SNP data. 
    For each SNP InfoProvider,
    create:
    1) Export Data:
    1.a)  Create an export data source, InfoPackage, comm structure, etc. necessary to create an ASCII fixed length flat file on the XI
    ctnhsappdata\iface\SCPI063\Out folder for each SNP InfoProvider. 
    1.b)  All fields in each InfoProvider should be exported and included in the flat file. 
    1.c)  A process chain should be created for each InfoProvider with a start event. 
    1.d)  If the file exists on the target drive it should be overwritten. 
    1.e)  The exported data file name should include the InfoProvider technical name.
    1.f)  Include APO Planning Version, Date of Planning Run, APO Location, Calendar Year/Month, Material and BW Plant as selection criteria.
    2) Import Data:
    2.a) Create a flat file source system InfoPackage, comm structure, etc. necessary to import ASCII fixed length flat files from the XI
    ctnhsappdata\iface\SCPI063\Out folder for each SNP InfoProvider.
    2.b)  All fields for each InfoProvider should be mapped and imported from the flat file.
    2.c)  A process chain should be created for each InfoProvider with a start event. 
    2.d)  The file should be archived in the
    ctnhsappdata\iface\SCPI063\Archive directory.  Each file name should have the date appended in YYYYMMDD format.  Each file should be deleted from the \Out directory after it is archived. 
    Thanks in advance.
    Tyson

    Here's some info on working with plists:
    http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Introduc tion/chapter1_section1.html
    They can be edited with any text editor. Xcode provides a graphical editor for them - make sure to use the .plist extension so Xcode will recognize it.

  • Difference between Abstract Classes Vs Interface

    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

    There are more differences, and one really important is that abstract classes can also define class variables, while interfaces cannot. I think the question of when to use interfaces or abstract classes is not always easy to answer, but yourself have pointed some tips you should be aware of :
    If you need that some funcionality of the class is derived by more than one "parent" then you should use interfaces, since you cannot extend more than one class.
    If your "superclass" needs to define some class variables then the choice must be made to have a superclass and then extend it. Also this is applicable if there is a method that can be programmed at a higher level (in interfaces you cannot program methods).
    But the answer to the question is still not easy. And remember, you can always mix both tipes, you can extend one class and implement some interfaces.
    Examples or that are very common in the Java API for AWT or Swing components, for example javax.swing.JLabel extends javax.swing.JComponent (that is beacuse a JLabel IS a JComponent and it uses some variables and methods programmed at the JComponent "level") and it also implements some interfaces: Accessible, ImageObserver, MenuContainer, Serializable & SwingConstants.
    I hope this helps.
    Zerjillo

  • Abstract class Vs interface

    Hi,
    I have to buid a report in ECM with complete details of the engineering as well as production. This include workflow as well as various fucntionality depends upon the criterion and user's event.
    I am implementating in OOPS and I Want to know that when I should use the Abstract class and when interface  ?
    Because as per me both serve the same purpose. Kindly send me the exact difference so that i can efficiently use the same.
    Thanks
    Prince

    When inheriting A Interface We have to inherit all the methods of the Interface there's no other option whereas with abstract classes we can inherit the members that we are in need of.
    Just the interface has to have body of the method and the method is to be used by the classes inheriting it. Whereas in the case of Abstract Class it can have declarations (Other than the abstract method) and it can be further extended in the classes inheriting the Abstract Class.
    Interface contains all abstract methods,all methods compulsory implemented by particular class, interface does not contain Constructor
    abstract classes are designed with implemantion gaps for sub-class to fill in.
    interfaces are sintacticlly similar to classes but they lack insance variables & methods.
    abstract classes can also have both abstract methods & non-abstract methods. where as in interface methods are abstract only, & variables are implicitly static&final
    regards
    Preetesh

  • JWSD RPC: abstract class or interface aren't working

    I have an abstract class called Record, and some classes that extend Record. These class have been added in the additionalTypes part of the configuration file (a copy of the config.xml is shown below)
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration
    xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
    <service name="sscService"
    packageName="ssc"
    targetNamespace="http://www.eurice.de/infocitizen/ssc"
    typeNamespace="http://www.eurice.de/infocitizen/type/ssc">
    <interface name="ssc.server.SupplierPort"
    servantName="BasicSupplier"/>
    <typeMappingRegistry>
    <additionalTypes>
    <class name="ssc.ConnectionSpec"/>
    <class name="ssc.InteractionSpec"/>
    <class name="ssc.MappedRecord"/>
    <class name="ssc.IndexedRecord"/>
    <class name="ssc.server.ResultSet"/>
    <class name="ssc.server.SOAPNull"/>
    <class name="ssc.ResultSetMetaData"/>
    <class name="ssc.Entry"/>
    <class name="ssc.SupplierMetadata"/>
    <class name="ssc.EISMetadata"/>
    <class name="ssc.cl.BirthCertificate"/>
    </additionalTypes>
    </typeMappingRegistry>
    </service>
    </configuration>
    However the xrpcc tool issues the following error message:
    E:\Projects\ssc\.\xrpccServer\ssc\Record_SOAPSerializer.java:33: class ssc.Recor
    d is an abstract class. It can't be instantiated.
    Record instance = new Record();
    Can you help me?

    OK, I took your record class as is:
    public abstract class Record {
    private java.lang.String recordId;
    private java.lang.String name;
    private java.lang.String shortDescription;
    public java.lang.String getName() {
    return name;
    public void setName(java.lang.String name1){
    name=name1;
    public java.lang.String getShortDescription() {
    return shortDescription;
    public void setShortDescription(java.lang.String shortDescription1){
    shortDescription=shortDescription1;
    public java.lang.String getRecordId() {
    return recordId;
    public void setRecordId(java.lang.String id1){
    recordId=id1;
    Added a subclass:
    public class MyRecord extends Record {
    private int age;
    public MyRecord() {}
    public void setAge(int age) {
    this.age = age;
    public int getAge() {
    return age;
    Used the record in a service endpoint interface:
    public interface Interface extends Remote {
    public Record echo_Record(Record record) throws RemoteException;
    Put MyRecord as an additionalType in the config.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration
         xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
    <service name="Interface_Service"
    targetNamespace="http://echoservice.org/wsdl"
    typeNamespace="http://echoservice.org/types"
    packageName="stub_tie_generator_test">
    <interface name="stub_tie_generator_test.Interface"
    servantName="stub_tie_generator_test.InterfaceImpl"/>
    <typeMappingRegistry>
    <additionalTypes>
         <class name="stub_tie_generator_test.MyRecord"/>
    </additionalTypes>
    </typeMappingRegistry>
    </service>
    </configuration>
    And invoked the method with:
    Record rec = new MyRecord();
    ((MyRecord)rec).setAge(33);
    rec.setShortDescription("short");
    rec.setName("name");
    rec.setRecordId("id");
    Record returnedRec = stub.echo_Record(rec);
    assertTrue(((MyRecord)rec).getAge() == ((MyRecord)returnedRec).getAge());
    assertTrue(rec.getShortDescription().equals(returnedRec.getShortDescription()));
    assertTrue(rec.getRecordId().equals(returnedRec.getRecordId()));
    assertTrue(rec.getName().equals(returnedRec.getName()));
    and everything works. I am not sure what the problem you are having is.
    May I suggest you try my simplified example and see if it works for you.

  • Abstract Classes VS Interfaces

    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

    LOL :)
    Anyway, it is very common to have a situation where some classes have a lot in common, but not everything...
    You can use an abstract class to do the common things, and define abstract methods for the things the overriding classes must implement themselves...
    public abstract class SomeClass {
        public void doCommon() {
            System.out.println("All classes should print this line :)");
        public abstract void doSpecific();
    }

  • Abstract Classes versus Interfaces

    Somebody at work has just made an interesting observation and its bugging me, comments please.
    When I started Java I just used classes (and abstract classes), and didnt bother with Interfaces I understood them to be a way of getting round the lack of MultipleInheritance and it wasnt a problem that concerned me.
    But as time went on I found that sometimes I did want classes that had little in common to provide some additional feature (such as logging), and interfaces were great for this.
    ..so I was happy ..
    During all this time if I want a HashSet I would write code like this
    HashSet dataSet = new HashSet();but then I read that HashSet was an implementation detail and we should be using Interfaces as follows:
    Set dataSet = new HashSet();So whereas before I might have had a class hierachy with an Abstract class at the top , I started slotting in Interfaces above that and viewing the Abstract class as just a convenience to implementing the Interface.
    So which is the right method , originally I saw subclassing object as an 'is a ' relationship and implementing an interface as a 'implements' relationship. But more recently it seems to be turned on its head and implementing an interface is an 'is a' relationship (but supports multiple inheritance)
    Also it seems to be the trouble with this second approach is that anyone can implement an interface, for example I could implement Set,Map and List with one class, the class hierachy is not so helpful .

    Thanks, but the question was alot wider than that,
    the HashSet example was just one part of it.I think it is representative of all the situations that you talk about, which are whether an instantiator should handle the instantiated object by its interface or by its implementation.
    I suppose the question is
    "How do you code model "is a " relationship in java
    through extending a class or creating an interface
    and implementing it"
    MySubClass extends MySuperClass implements MyInterface {}MySubClass is a MySuperClass and a MyInterface. The way that I view it, the "is a" relationship applies to all type inheritance, even for the multiple type inheritance that you can have with interfaces. The "is a" relationship doesn't doesn't have to be a 1:1 mapping. There's no point in thinking about it differently since that's how the language behaves.
    an alternative question is
    "is it correct to mix/match both methods I described
    above"I thought I gave an answer. You said that my answer is not "broad enough." How so? My answer was that handling an object that you instantiate by its interface can reduce the amount of changes you have to make if you change the implementation. You will have to make one change (the line of code that instantiates the object) instead of many. Also, handling it by its interface makes it easier to switch from object A instantiating object B to object A being passed a reference to B and to object A getting its dependencies injected by XML configuration.
    It seems weird to handle an object by its interface if you already know it's implementation, but it's commonly seen and this is why I think it must be used. As I said, it's a small benefit of abstraction.
    The times when you may not want to do this is when the instantiator has to call methods from different interfaces of the object. You can handle it by its interface by casting between the different interfaces you have to work with, or you can just handle it by its implementation, gaining access to all of the object's interfaces.
    Note that everything I explained concerns the type by which the instantiator handles an instantiated object. If a class does not instantiate a certain object, then it almost always should receive it by its interface, unless it's some really common implementation that's never going to change.
    I use interface, abstract class, and base class interchangeably. It's up to you to decide which to use for type inheritance. It's good practice to favor interfaces.

  • Abstract Class X Interfaces

    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 ?

    Classes can implement any number of interfaces but can extend only one class. Interfaces are used when a class might want to implement that interface but extend another class. However, interfaces cannot have implementation, so that's what abstract classes are used for.

  • Return an abstract class or interface

    I have an abstract class Exercise with concrete subclasses GlobalExercise, FreeweightExercise, EquipmentlessExercise and MachineExercise. I am trying to write a method that takes in an Exercise name and returns the object with that name.
    What is the best way to do this? Is the code below reasonable if I change it to Exercise exer = null.
    Exercise getExercise(String name) {
            Iterator i = exercises.iterator();
            Exercise exer;
            while (i.hasNext()){
                exer = (Exercise)i.next();
                if (name.equals(exer.getName())){
                    break;
            return exer;
            Iterator i = exercises.iterator();
            Exercise exer;
            while (i.hasNext()){
                if (i.next() instanceof GlobalExercise){
                    exer = (GlobalExercise)i;
                    if (name.equals(exer.getName())){
                        break;
                else if (i.next() instanceof FreeWeightExercise){
                    exer = (FreeWeightExercise)i;
                    if (name.equals(exer.getName())){
                        break;
                else if (i.next() instanceof MachineExercise){
                    exer = (MachineExercise)i;
                    if (name.equals(exer.getName())){
                        break;
            return exer;
        }

    The code is reasonable if in most cases you won't be using it ;).
    You appear to have the exercises in a list, so if you normally access each exercise in turn, then this code is fine.
    If, however, you normally use the name to access the exercise, the put the exercises into a HashMap instead, and use the name as the key.
    Pete

  • Abstract class with set and get methods

    hi
    how to write set and get methods(plain methods) in an abstartc class
    ex: setUsername(String)
    String getUsername()
    and one class is extending this abstract class and same methods existing in that sub class also..... how to write......plz provide some ideas
    am new to programming....
    asap
    thnx in advance

    yes... as i told u.... i am new to coding......
    and my problem is ..... i have 2 classes one is abstract class without abstract methods.. and another class is extending abstract class.....
    in abstract class i have 2 methods...one is setusername(string) and getusername() ..... how to write these two methods.... in abstract class i have private variables username...... when user logins ..... i need to catch the user name and i need to validate with my oracle database and i need to identify the role of that user and based on role of that user i need to direct him to appropriate jsp page.......
    for that now i am writing business process classes..... the above mentioned two classes are from business process.....
    could u help me now
    thnx in advance

  • Exporting and importing table using R3trans program between 2 clients

    Hi,
    How to export and import a table between to clients in a same system using R3trans program?
    I need to copy a table from Client 020 in a system to client 040 of the same system using R3 trans. I need to know the procedure.
    Can any one advice
    Regards,
    Suresh

    This is how you do a export and import of table entries.
    Export:
    Open Notepad and type the following,
    export
    client = 020
    file = 'clone.export.<sid>.<client no>.data'
    select * from <client_dependent_tablename1>
    select * from <client_dependent_tablename2>
    select * from <client_dependent_tablenamen>
    Save the file as export.ctl
    Run R3trans export.ctl
    and the data of these files will be stored in a file called clone.export.<sid>.data in the directory from which you have called R3trans
    Import:
    Open Notepad,
    import
    client = 040
    file = clone.export.<sid>.<client no>.data
    buffersync = yes                                               
    Save the file as import.ctl
    Run R3trans import.ctl
    Cheers!
    Bidwan
    Message was edited by:
            Bidwan Baruah

  • Extend abstract class & implement interface, different return type methods

    abstract class X
    public abstract String method();
    interface Y
    public void method();
    class Z extends X implements Y
      // Compiler error, If I don't implement both methods
      // If I implement only one method, compiler error is thrown for not
      // implementing another method
      // If I implement both the methods,duplicate method error is thrown by 
      //compiler
    The same problem can occur if both methods throw different checked exceptions,or if access modifiers are different..etc
    I'm preparing for SCJP, So just had this weired thought. Please let me know
    if there is a way to solve this.

    Nothing you can do about it except for changing the design.
    Kaj

  • How I can Export and Import tables using BRTOOL ?

    Dear All,
    Since we upgrade the oracle from 9.0.2 to 10.2.2 we not using SAPDBA any more.
    please help me if you now how to export and import tables in sapr3 using brtools?
    thanks and Best regards,
    Chrisna

    Dear Chrisna,
    first of all you should get the recent version of the BRTOOLS (currently it's BRTOOLS 7.00 (<b>26</b>)). The developers are working hard on making these tools more reliable and usable so you should not deny the improvements to yourself.
    Now to your problem:
    Try this call:
    brspace -f tbexport -o SAPR3 -t SSF_PSE_D,SSF_PSE_H,HTTPURLLOC
    You don't need to specify a tablespace; it's just a additional option to select what tables you like to export.
    You may also want to check these notes for further "enlightment"
    <a href="http://service.sap.com/sap/support/notes/976435">#976435     Support for Oracle Data Pump in BRSPACE</a>
    <a href="http://service.sap.com/sap/support/notes/713497">#713497 - New BRSPACE options for "Reorg", "Rebuild" and "Tablespace"</a>
    <a href="http://service.sap.com/sap/support/notes/647697">#647697 - BRSPACE - New tool for Oracle database administration</a>
    <a href="http://service.sap.com/sap/support/notes/646681">#646681 - Reorganizing tables with BRSPACE</a>
    <a href="http://service.sap.com/sap/support/notes/12741">#12741 - Current versions of BR*Tools and SAPDBA</a>
    <a href="http://service.sap.com/sap/support/notes/651812">#651812 - FAQ: BR*TOOLS and SAPDBA</a>
    KR Lars

  • What's exact meaning for interface ,and where we use this interface

    hi experts,
    i have been asked what is interface

    Hi
    Interfacing is connecting two or more different entities. In our case, it is connecting one or more systems with SAP. Now extending our previous example, you are replacing some legacy applications but there are some applications that you don't want to replace yet. You need to somehow pass data back and forth between SAP and these remaining systems. Data may be going one way or the other way or both ways. You will still need to do some data transformations/translations etc to make the data understandable to the receiving system. This will continue as long as you want to keep the systems running alongside SAP.
    In short, conversions are written to load data into SAP onetime. These are typically file based.
    Interfaces are written to exchange/update/send/receive data between SAP and other systems on an ongoing basis. These can be in many forms, file based, idoc based, real time(business connector, XI etc are useful in this), xml, and the list goes on.
    Reward me if its helpful
    Ravi

Maybe you are looking for

  • Problem with Date Picker Item

    Hello, I'm using APEX 4.2.2.00.11 and I have a problem with the Date Picker. I can't select any day of the second week of the month (it happens for all months). Someone know if there are any reason (and how can I solve it) or is an APEX bug? Thank yo

  • Best way to archive a project when it's "finished"

    I was wondering what the best way is to store a project that is finished, but you still want the option of going back and modifying for other purposes. Do you create one high quality movie and save it? Do you create separate clips of everything used

  • What does a globe at the folder icon mean?

    When I installed RH9 or at least after I imported my first project into RH9 I got a folder under \Users\me\Documente\Eigene Robohelp Projekte This folder appears with a globe symbol attached to the folder icon? What is the special meaning of that fol

  • Setup a new Ship to and sold to party

    I lost my sd/pp config person and need to setup a new ship to and sold to party (HELP!!!)

  • 2.1 - faster backup?  Oh heck yes!

    Syncing and backing up with 2.1 are now wonderfully fast. Just thought I'd toss that out there - comparing the 3G iPhone with 2.0.2 and the same setups, it kills it in speed. Can't wait until tomorrow for the 2.1 for iPhone. Scott