Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

difference between abstract class & Interface?

Former Member
0 Kudos

difference between abstract class & Interface?

8 REPLIES 8

Former Member
0 Kudos

Please give me reward points...

GrahamRobbo
Active Contributor

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

Former Member
0 Kudos

Hi

former_member2382
Active Participant
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

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

former_member778361
Discoverer
0 Kudos

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.

0 Kudos

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.