Home ABAP Tutorials ABAP Objects Abstract and Final Classes
Abstract and Final Classes PDF Print E-mail
User Rating: / 7
PoorBest 
ABAP Tutorials - Object Oriented ABAP
Written by Varun Verma   
Tuesday, 09 September 2008 17:42

Abstract Classes:

A class that is defined as ABSTRACT cannot be instantiated. This means that you cannot use CREATE OBJECT with reference to the class. If a class contains any abstract method then the whole class becomes abstract. A method, which is abstract, should be redefined in derived class. An Abstract class can declare and implement non abstract methods which its subclasses can use with or without redefining them.
The use of abstraction through abstract classes is restricted to the sub classes of a specific node within the inheritance tree.
The syntax to define a method as abstract method is shown below. Note if you are working with global classes then in the SE24 transaction you can define a class as abstract class in the properties tab.

Abstract class

Why use a abstract class?
An abstract class is used when we want to model an object, the final state of which is not known at the time of modelling and will be known later.

Final Class:

A class that is defined as final class can not be inherited further. All Methods of a final class are inherently final and must not be declared as final in the class definition. Also, a final method can not be redefined further.
If only a method of a class is final then that class can be inherited but that method cannot be redefined.

Syntax for final class
:
CLASS final_class DEFINITION FINAL.
  METHODS final_method FINAL.
ENDCLASS.

Why use a final class?
If you don't want anyone else to change or override the functionality of your class then you can define it as final. Thus no one can inherit and modify the features of this class.

Comments
Add New Search
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Advertisement

 

Google Search

Advertisement