Sie sind auf Seite 1von 13

Abstract Class: Classes which contain one or more abstract methods or abstract properties, such

methods or properties do not provide implementation. These abstract methods or properties are
implemented in the derived classes (Sub-classes).
Abstract classes does not create any instances to that class objects
Use of Abstract class:
e can de!ine some common !unctionalities in Abstract class (Super-class) and those can be used in
derived classes (Sub classes).
Step-by-Step Approach to create Abstract classes and Methods
TCode: S"#$
"nter the name o! class as %&'(")*'A+S'C,ASS% and press Create +utton

A pop-up window is displayed, then select -Class- radio button and
.ress enter

/t will 0o to the ne1t screen.
2ere you enter the (escription o! the class and then select -Abstract- !rom /nstantiation (rop down list to
de!ine the class an abstract class,
Then clic3 on save button

4o to the -Attributes- tab,
"nter the Attribute name, ,evel, 5isibility, Type and (escription as shown in the screen shot.
4o to )ethods tab,
"nter )ethod name, ,evel, 5isibility and (escription as shown in the below screen shot
(ouble clic3 on the )ethod name -A6"A-7 it 0oes to method /mplementation screen.
4o to )enu path, then 4oto -8 )ethod de!inition

.op-up window is displayed. /t 0ives complete in!ormation o! the method
To de!ine method -A6"A- as an abstract method,
4o to -Attributes- tab, chec3 the chec3 bo1 -Abstract-
hen you clic3 on the -Abstract- chec3 bo1, pop-up window is displayed,
then press button.
Then press -Chan0e- button.

A success!ul messa0e is displayed li3e -)ethod chan0ed success!ully-

Creating Sub Class:
TCode: S"#$
"nter the name o! class as %&'(")*'A+S'S9+'C,ASS% and press Create +utton to create sub class

A pop-up window is displayed, then select -Class- radio button and
.ress enter

/t 0oes to ne1t screen, here you enter the (escription o! the class and then
Select the inheritance button , to inherit the super class then press button

"nter the Super class name as -&'(")*'A+S'C,ASS-, which is bein0 created earlier and press
button.

The Attributes and methods de!ined in the super class will automatically come into the sub class. See the
below screen shots.

4o to the )ethods tab, select the -A6"A- method and clic3 on
-6ede!ine- button
/! you are not 6ede!ine the method and tryin0 to activate the class, it 0ives synta1 error.
2ere you can write the code

rite the code /n between )ethod and "nd )ethod
Method AREA
....
Endmethod
rite the below code
method AREA
: ,ocal (ata (eclarations
(ATA: lv'count T;." i,
lv'res T;." i.
: initiali<e Count value to %=%
lv'count > %=%.
(* =? T/)"S.
/@ lv'count A> %=?%.
lv'res > v'num : lv'count.
: (ispla the multiplication table !or a 4iven Bumber
6/T": C v'num,
%:%,
lv'count,
%>%,
lv'res.
: /ncrement Count value
lv'count > lv'count D =.
",S".
"E/T.
"B(/@.
"B((*.
: Clear variable
C,"A6: v'num.
endmethod
Then save and activate the class and method.
@inally e1ecute the class (@F)
/t 0oes to below screen
"nter the number under 5'B9) as -G- and press e1ecute button .

The out will be displayed li3e below.

Das könnte Ihnen auch gefallen