11-05-2007 8:56 AM
11-05-2007 9:10 AM
11-05-2007 10:10 PM
Hi Prahlad,
an interface contains <b>no implementation</b>, just the definition. The definition is the name of the class, the name of the methods, the name and type of the class attributes and the method parameters. The implementation is essentially the abap source code contained in the methods.
An abstract class contains <b>both definition and implementation</b> but cannot be instantiated. You can only use an abstract class to create subclasses.
Cheers
Graham Robbo
11-06-2007 5:57 AM
11-06-2007 10:39 AM
Abstract class is the class in which there is atleast one
abstract method.abstract method is the method which does not
have any body defined in that class.We cannot make any object of
the abstract class.So, that abstract class must be derived by
the subclass which defines all the abstract methods of the super
class.If the sub class doesnot define any abstract meth. of the
super class, then that sub class automatically becomes the
abstract class.When the sub class defines all the abs. meth.s of
the super class then we can make the object of the sub class and
access the other methods of the abs. super class.
An interface is the class that have all the methods as abs.
methods.All the instance variables of an interface must be
declared as final and static.Now we can implement this interface
in another class which must define all the methods of the
interface.Now make the obj. of the class that implemented the
interface.
Interfaces are used where we want the users to use the specified
methods only.Abstract classes are used in inheritence where
there is no need for the class to define any method which must
be defined in the sub classes.
Please the feedback for the above answer.There's too much about
the abstract class n interface so i could not write everything.I
think this must clear ur doubts.
Regards,
Parvez
11-06-2007 11:26 AM
Hi Prahlad,
The basic difference between Abstract class and interface is abstract class will have implementation and Interface will not have any implementation. Basically we will go for abstract classes when we want to write partial implementation of the class.
Reward points if useful,
Aleem.
01-01-2021 12:54 PM
Hi ,
Interface:
1. Can contain only abstract methods.
2. By default all methods are abstract.
3. All components of interface by default are public.
4. Interface components must be prefixed with the name of the interface.
Abstract Class:
1. Can contain both abstract and non-abstract methods.
2. Explicitly we need to use abstract keyword.
3. Abstract methods can be declared in public or protected section.
4. A class can inherit only one abstract class.
5. Abstract class components are directly referred in subclass.
regards,
Nasreen
11-27-2021 8:24 PM
Interface in SAP is a mechanism to achieve 100 % abstraction.
There can only be abstract methods not a method body.
it is used to achieve the multiple inheritance.
The main goal of abstraction is to handle the complexity by hiding unncessary details from the user.
11-27-2021 8:24 PM
Thanks for coming to SAP Community for answers. The original question has received a helpful answer already, please post your question as a new question here:
Since you're new in asking questions here, check out our ourtutorial about asking and answering questions (if you haven't already), as it provides tips for preparing questions more effectively, that draw responses from our members.
Please note, that your post here won't be answered.