You are on page 1of 2

report z745oops11.

Instance and Static


constructors execution
class abc definition.
public section.
methods constructor. "instance const
class-methods class_constructor. "static const
methods m1. "instance normal method
class-data x type i. "static attr
endclass.
class abc implementation.
method constructor.
write :/ 'inside instance constructor...'.
endmethod.
method class_constructor.
write :/ 'inside static constructor...'.
endmethod.
method m1.
write :/ 'inside instance method m1....'.
endmethod.
endclass.
start-of-selection.
abc=>x = 10. "invokes static const
uline.
write :/ 'First object creation....'.
data ob1 type ref to abc.
create object ob1.
*call method ob1->constructor. "syntax error as const cannot be
called explictly
uline.
write :/ 'Calling instance normal method m1 multiple times using
same object....'.
call method ob1->m1.
call method ob1->m1.

uline.
write :/ 'Second object creation....'.
data ob2 type ref to abc.
create object ob2.
uline.
write :/ 'Third object creation....'.
data ob3 type ref to abc.
create object ob3.

You might also like