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: 

static

Former Member
0 Kudos
103

what is the purpose of a static constructor and can a static methos be overrrided.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
81

Hi,

The purpose of static constructor is to initialise static attributes.

As the static method appears for a class you can not override a static method.

Reward points if useful,

Aleem.

2 REPLIES 2

Former Member
0 Kudos
82

Hi,

The purpose of static constructor is to initialise static attributes.

As the static method appears for a class you can not override a static method.

Reward points if useful,

Aleem.

Former Member
0 Kudos
81

HI Sandeep,

usually constructors are used to initialize variables.

Static Constructor is used to Initialize static variables.

The static methods are executed with higher priority without any instance ....

they cannot be overwritten.

for more info..

A static method can be called without prior instatiation of the class. This is the technical aspect. When do we define a method as static? If the method does not need to know any details of an instance then I would define this method as static. This is the semantic aspect.

Typical examples are utility methods, calculations, etc.

Example: class CL_ABAP_CONTAINER_UTILITIES

Its static methods convert either a string into a structured data type or vice versa. For this purpose the methods do not need any knowledge of any instances, the input is sufficient enough.