Skip to Content
author's profile photo Former Member
Former Member

ABAP Objects.. Abastract & Interface Class

What are the differences between Abstrac & Interface Class.. & In which condition we use abstract class and interace in Abap Objects?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 06:55 AM

    Abstract Classes are provided as incomplete blueprint for complete subclasses.

    Classes with atleast one abstract method are themselves abstract.

    Interfaces are provided additional and independent of classes. They just describe which services are needed for a task to be carried out, but do not provide an implementation of the same.

    It is similar (but not same) as an abstract class that only contains abstract methods.

    Similarities between Interface and Abstract classes.

    1. Both CANNOT be instantiated.

    2. Can have references to both of them, which can hold objects of subclasses.


    1. Abstract classes contain one or more abstract methods - abstract methods are those which cannot have an implementation in the class itself.

    2. Interfaces have all their methods abstract - none of them can have an implementation.

    3. No visibility sections (PUBLIC, PRIVATE, PROTECTED) can be defined for interfaces, but can be defined for abstract classes.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Ranveer,

      Performance wise, I would advise you to go for interfaces.

      Interfaces are more generic than abstract classes. So, they have a wider acceptance and wider applicability.

      If you do not know the nature of subclasses that will require inheritance, go for interfaces.

      By coding abstract classes, you would be restricting atleast some if not all your development for further use of your subclasses. You would require to be very clear about certain functionalities of the abstract class and subclasses when you design abstract classes.

      Unless you have a very specific design reason to do so, do not go for abstract classes.



  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 08:05 AM

    hi ranveer,

    You cannot instantiate objects in an abstract class. This does not, however, mean that references to such

    classes are meaningless. On the contrary, they are very useful, since they can (and must) refer to

    instances in subclasses of the abstract class during runtime. The CREATE-OBJECT statement is extended

    in this context. You can enter the class of the instance to be created explicitly:

    CREATE OBJECT <RefToAbstractClass> TYPE <NonAbstractSubclassName>.

    Abstract classes are normally used as an incomplete blueprint for concrete (that is, non-abstract)

    subclasses, in order to define a uniform interface, for example.

    Abstract instance methods are used to specify particular interfaces for subclasses, without having to

    immediately provide implementation for them. Abstract methods need to be redefined and thereby

    implemented in the subclass (here you also need to include the corresponding redefinition statement in the

    DEFINITION part of the subclass).

    Classes with at least one abstract method are themselves abstract

    Static methods and constructors cannot be abstract (they cannot be redefined).

    Interface only has a declaration

    An interface corresponds to an abstract class that

    only contains abstract methods

    Interfaces are implemented in classes

    Interfaces do not have visibility sections

    Hope this is helpful, Do reward.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 08:19 AM


    Abstract class is a class which contain one or more abstract methods, which has to be implemented by sub classes. Inteface is a Java Object containing method declaration and doesn't contain implementation. The classes which have implementing the Interfaces must provide the method defination for all the methods.2. Abstract class is a Class prefix wtih a abstract keyword followed by Class definaton. Interacace is a Interface which starts with interface keyword.3. Abstract class contatins one or more abstract methods. where as Interface contains all abstract methods and final declarations.4. Abstract class contains the method defination of the some methods. but Interface contains only method declaration, no defination provided.5. Abstract classes are useful in a situation that Some general methods should be implemented and specialization behaviour should be implemented by child classes. Interafaces are useful in a situation that all properties should be implemented we can use this scenario.

    the main differences between an interface class and abstract class are

    1.abstract classes must be given by keyword abstract,where as in interface class with key word interface

    2.every method in interface class should be abstract,but this is not necessary in abstract class default what ever variables we decalre in interface are public static final,where as in abstract class they can be default and instance variables also



    kindly reward if helpful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 09:08 AM


    Abstraction is used to manage complexity

    Focus on the essential characteristics

    Eliminate the details

    Find commonalities among objects

    Defines the public contract

    Public definition for users of the object

    The “Outside view”

    Independent of implementation

    Interfaces are independent structures that you can implement in a class to extend the scope of that class.

    a universal point of contact.

    They provide one of the pillars of polymorphism, since they allow a single method within an interface to behave differently in different classes.

    Global & Local Interfaces

    The definition of a local interface <intf> is enclosed in the statements:

    INTERFACE <intf>.



    The definition contains the declaration for all components (attributes, methods, events) of the interface.

    They automatically belong to the public section of the class in which the interface is implemented.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.