Vous êtes sur la page 1sur 4

Today' class:

___________________
Different types of Attributes in Runtime artifact Class
---------------------------------------------------------1) Instance attribute/variable
2) static attribute/variable ( or ) class variables
3) Constant
____________________________________________________________
Constant :
----------for Constant the initial value is MANDATORY.
AND THAT INITIAL VALUE of constant WILL be fixed value.
constant value can be accessed using "OBJECT reference"
"CLASSNAME"
Constants will be generated globally for all objects of that class
i,e

obj1, obj2, obj3 can access constant value ( bcoz constant is global )

instance attribute:
----------------for instance attribute , the initial value is OPTIONAL
and the value of instance attribute can be modified
instance attribute value can be accessed using "OBJECT REference" only
instance attributes will be generated locally for each and every separate object
i,e

obj1 has separate memory for Instance attribute


obj2 has separate memory for Instance attribute
obj3 has separate memory for Instance attribute

static Attribute:
---------------for static attribute, the intial value is OPTIONAL
and the value of static attribute can be modified.
static attribute value can be accessed Using "object Reference'
"CLASSNAME"
static attribute is generated globally for all objects of that classs.
________________________________________________________
Note : for a classs, we can create any number of Objects
_____________________________________________________________
Note : For an Object, The memory is allocated based on 3 factors:
1) based on TYPE of Attribute
2) based on the Data TYpe of each attribute
3) based on the Number of Attributes

____________________________________________________________
_______________________________________________________
according to the diagram:
Obj1 can access/modify its own EMPID , its own EMPNAME
___________________________________________________________
obj2 cannot access/modify OBj1 related EMPID, EMPNAME
______________________________________

static attribute value can be modified/accesed by any object at point of time in


program
and moreover
static attribute contains the latest value
___________________________________________________

Difference between static Methods and Instance Methods:


______________________________________________________
THe Type of Method is decided based on the "TYPE of ATTRIBUTE"
Static Methods
-------------------static Methods can access only "STATIC ATTRIBUTES" only.
----------------i.e,
static methods has capability to access only GLOBAL Memory section.
-------------Static Methods can be accessed using "OBJECT REFERENCE"
"CLASS NAME"
i,e
For accessing static methods "object creation" is optional

Instance methods:
-------------------Instance methods can access both STATIC Attributes
+
Instance attributes
i,e
Instance methods can access both Global Memory
+
Local Memory
Instance Methods can be accessed using "OBJECT REFERENCE " only

For accessing Instance methods "oBject creation" is MANDATORY"


_____________________________________________________________________
IN OOABAP , we have two types of Objects:
-----------------------------------------1) Implicit objects -> Objects which are given by SAP.
For EX :
ME
SUPER
2) Explicit Objects-> Objects which are created by developer in their programs
for EX : create object Obj1.
create object obj2.
create object obj3.
____________________________________________________________________________
ME Keyword :
__________________
Me is a keyword or Implicit object.
ME is a "Self-REFERNCE" of that class.
-------------Me is used to access Instance attribute of the same class.
Me is used to access Static Attribute of the same class.
Me is used to access Method of the same class
_____________________________________________________
Inside Instance Method, we can use ME keyword to access ,
INSTANCE attribute, StaticAttribute, Intance method , STATIC Method
____________________________________________________________________
Inside Static Method, we cannot use ME keyword to access
INSTANCE attribute, Static Attribute, Instance method , STATIC Method
______________________________________________________________________

Vous aimerez peut-être aussi