0% found this document useful (0 votes)
165 views2 pages

Constructor and Class-Constructor - Instance Constructor and Static Constructor - SAPTech

Each class can have one instance constructor named CONSTRUCTOR that is automatically called with CREATE OBJECT. The constructor must be defined in the PUBLIC SECTION and can have importing parameters and exceptions. Each class also has one static constructor named CLASS_CONSTRUCTOR that is executed once per program before the class is first accessed or a static method/attribute is called. The static constructor must be in the PUBLIC SECTION and cannot have parameters or exceptions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views2 pages

Constructor and Class-Constructor - Instance Constructor and Static Constructor - SAPTech

Each class can have one instance constructor named CONSTRUCTOR that is automatically called with CREATE OBJECT. The constructor must be defined in the PUBLIC SECTION and can have importing parameters and exceptions. Each class also has one static constructor named CLASS_CONSTRUCTOR that is executed once per program before the class is first accessed or a static method/attribute is called. The static constructor must be in the PUBLIC SECTION and cannot have parameters or exceptions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

4/13/23, 12:33 PM Constructor and class-Constructor / Instance Constructor and Static Constructor | SAPTech

Constructor and class-Constructor


19th March 2017
/ Instance Constructor and Static
Constructor

 Instance Constructor
The constructor is a special instance method in a class and is always
named CONSTRUCTOR.
The constructor is automatically called at runtime with CREATE
OBJECT statement.

Some Important points about constructor:

Each class can have only one constructor.

The constructor must be defined in PUBLIC SECTION.

The constructor's signature can have only importing parameters


and exceptions.

The constructor's signature can not have exporting parameters. 


When exceptions are raised in the constructor, instances are not
created so no main memory is occupied.

Static Constructor
This is a special static method in a class and is always names
CLASS_CONSTRUCTOR. It is executed once per program. This
constructor is called automatically before the class is first accessed,
but before any of the following actions are executed for the first time:

Creating instance of this class(CREATE OBJECT)

Accessing a static attribute of this class.

Calling a static method of this class.

Registering an event handler method for an event in this class.

Some important points:

Each class has only one static constructor

This constructor must be defined in PUBLIC SECTION.

The constructor's signature cannot have importing parameters or


exceptions.

The static constructor cannot be called explicitly

Facebook Page [https://www.facebook.com/mySAPTech]

Posted 19th March 2017 by Blogger

https://mysapnuts.blogspot.com/2017/03/constructor-and-class-constructor.html 1/2
4/13/23, 12:33 PM Constructor and class-Constructor / Instance Constructor and Static Constructor | SAPTech

0 Add a comment

To leave a comment, click the button below to sign in with


Google.

SIGN IN WITH GOOGLE

https://mysapnuts.blogspot.com/2017/03/constructor-and-class-constructor.html 2/2

You might also like