Define A Class in Apex
Class:
Class is a collection of
data members and methods.
Ex: class student
{
Integer no;
String name; → these are data members of the class
Public void gets
Details ()
{
System. Debug
(‘roll no’ +no);
System. Debug (‘name ‘+name);
}
}
EX2 :
class employee
{
Integer exp ;
String deportment;
Void show ()
{
//write the logic
}
}
To define an apex class, specify the following.
a) Access
modifiers:
I.
You must use one of the access modifiers for
top level class. (public or global)
II.
You do not have to use access modifiers in the
declaration of inner classes.
b) Optional
definition modifiers such as virtual, abstract.
c) Required:
the key word class followed by the class name.
d) Optional
extensions: AND/OR implementation
Syntax:
Private| public | global [virtual | abstract| with sharing | more]
Class
class name [implements interface Name list|
(none)]
[extends class name |(none)]
{
// the body of class
}
No comments:
Post a Comment