class
set of
properties and methods are grouped into single unit.
syntax:
class classname
{
//variable
dec & initialization;
//method
definition
dtype
vname1,vname2,,,;
.
returntype
mname(dtype1 vname1,dtype2 vname2,,)
{
set of
exe sts;
return
rvalue;
}
}
Creating instance of a class:-
"new" is a keyword to create an instance of a
named class.
syntax:-
classname <objname>=new constructorname(args);
eg:-
Demo d1=new Demo();
(or)
Demo d1; //obj
declaration
d1=new Demo(); //obj
initialization
No comments:
Post a Comment