0% found this document useful (0 votes)
4 views

Function Theory

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)
4 views

Function Theory

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/ 15

Page

122 Date.

FUnchoms and Mefhod


CAass- is Legical Lmshrut up
wuh endine shucthe de
Edeu the hah natuse
A clos3 di ur dala

Syntax Aass clas name

instance vonoble 1
instancevoxiable2
Lntan ce vona ble n
liit
tpe uthed nome 1 (paiaales

I/ body
wethod rnamen Parauadesut
tup

had

he data auo Mabiahle dind withu u tlau


Oh tlla intance undalle
Cde uCenatüud authads
BAth t muthtds 0sunle dau4
burzet
2
Page
Date

Hclaus
inbles dtned nithn la e called
nhance
A t n c e raiables ecouLe ach peet
remtauas
Cemtala4
L n Cby these2/mao
heh e dala 4rhebet
0
epasate and wnalLe m he_data
dnethe ee

ClassTnahgi{e
doubleb 2 insBance
ubleh variable

reain ec
OM
uhieh hare the
Cund behatLLS 03 20mechasdtEhhu
Ahared
lass A he
20tware
i t i nin am ableg and mplem G
haADALS WLth methods.
SUnd aX cas name obyeet amea ewK
obc o
dasomcd)
heur hmangle O
Uhe obicc
seSinstonce vamable with
dhehep o ) dor abea ator

Duzzet
Functhem
e e
xecuctnble natruetiansorchtAied

uncti.ans. 4
hetgh melhnls hméaleclasatim

KcAunce atatemen
Eeecutoble.
statemenis
LAa and
Lub-programmt within
uthiD
wtiuchprt rDLLLL da
maun Oregram
aho uins aue ut
hamepasamekes

Syntae tube

bodu

tybe Aata
data
KCNube-J spcutes
methseSE coh be
n m he
dala Tye
C CLn erwn Cuny
nchiom dae no
fhn_yhc 1&
-alu han

unchim Deinathon
ine theunchen
E Lthe s h

handa.ke
Aes specdieryLmadiler (rcktn tuhe\(kunchn ne)

bod

deeumuu t ambut
buzzet
Page
acceM Dete
he unction e n to be e t
he
OPublic mean& ta aLcessible

Birat Cnlu biLct e


QLceSRhe veriables &ame
&ame claSA (On
meh nclsaLan
methbels
Proteched-he
Coun e ariab les ound methoel
tesse d Hae Hhe &1b class
Medie 9t an e na toutie,
n c o nPo
meth6-d COun 9+ mla
K chan
meou metheds
uwithD ceating_ Can Ure called
net8 tetic h h pect J a methed
to CLcRR t

Ptuun yp
detesunnuwsHe t olato Lushech a
wwww uhuhcm
uhhn
eecuteo
e DrimilAe g nm +Can
an
w ve tbe
au han etugun
Page
Date

Fnchm name
Owmy hame r e t h a y elo
lE_Cah be
to the pocess. t muAt L ule
a identte

Purannedes ist
These eaiaaes

eluues paked
dusuns etiaed Call
m m amma Aepasoted Lut D
vaxiables,

Cassiucatlom o nCtims
1 Pare etined
untiom whh ahi awailoble iThih aa
packag nd can used lu imbarting
he requustd package
Exampe Math O
Mah sqr OAALU
2
User oleuued unchog
unhm & de P he Dommey
uoithin
pom nCLloc task
Ce Sum tactonal

Based
Based the tate the ore
etuwARd he hm hi a
Pune dhaa HCCeLsn me-thbea)
wuewnthn
buzzet
Mutatrr methielL
Page
PuLhe unchhom 6Date
retuttms mne
alu tot Colo L mo nchca
not
medle J eun
Vaue
4 called Called CLR
acceARr mth.sd knon a
nutatOm mehad
9E_doLs net chang
the dade oan msLDe2tnde
obect Changed each me
S Called
9+ CemtalaR euHn
L 9+ m
ma not
pa inonotidn a Lntain uuo
a bahoulas elueP khalernoent lut Charge
he inlte o eaejred

2Parawetz
E oomable ArguMPAAY
delasd hu a methrd R passeo
dhateiee Vkue methedwe t
aethhd u wweke
Called

alLoLLS neihed
0 e Qeneralued
A paaanndeaalise opehat
Ca
ubdate mm uantN
buzzet
dalo
Page
Date

int sauas

Yeturn iX

Jhe squase mehod


oletun
SquuaAe a tateuen
Velue Is

ActualPaxametta
Uhy abhea L lhu pbea in
Luhchm Col Uncthin cdetnatin.
method

Not preceded y Precedad th data


dalatb
Rel o the actu
alue passed to the alu p.aed n
unchm chcm

D int_mLLHply_int Xint y

Tetuswn
b L l b25
Ab whply LL b) Acw tohu
Dzzet
Page:
Oate:
Function hototybe Funchon S1ghatune
Tst ine o
nctiom deinahon Ha
-asically nee to
Hells +he numbef and ypes
oYam alrou
H ybe ovalue angumens
tusncd Unchm
the number and tyhe o
U
drUmen ts
helbs to delermine
Lohether heunchim is
Invovo ked ropery_0r not lb
masung fhe nLumber and
Te argument
iht amultp y int x int y
retuenm Siqna-ure

unctim Proto-fybe

Feample
Clags abc

void maun ( 0

int 5 26
int abc maelmtln 10
Susm sut piintln ("Greateut is z ) D
I d maeimum t a
i t b) ( )

a> b) e
buzzet r whn a
m
Page
Date

ex Class abe
int cube int a)

t h tn aa* a
e-uun h R

void main
iht X 5 , u 0 ,
: Cube (x) ,(1D
Sysiem-9Ltprintlnheube o +

Ketwuning a Value
ahe Juo poin o emember
The
Jupe odata 2efuhned hthe methad
mu e Campotble(samewith the eutn_
ybe Specifed h emethbd.
teample
F tusun ube methadi eoean
thaun toMot tuUnOn inttgL

D he OhLaHe LLLLAg tlue aluL HLUnLa


the muthd mAat alae
wnthe hututun LubeAerikd
the methbo

buzzet
Pege
IO lDate-

KetuunStadement
unchm mimates
when 0 uLua
Adattment
A ound
u s e t u l in twb ays
)Animmediale exit om the unctim
&ten Qstu ound and he mhr
passes ack he caller mo-dule.

t wAedoetuneuun a vaue o he
Co lleng CEde
A tnt
omCoum Con tan 3enesal metuun Statemt
Jout 6ne
hem 9et exeuttd
cauuie 300m as t N
ound the ere uutiom
e r minated

A uctionCo e imvokes two methoels-


Call bi Value Pass by valu)
Call b4 Relerence ce (Pau by en0 nte

Call By Value
tCbie the ale attualparamele3
inko m a l pohautK. e uncthon
Ctotes otCwm Cob
ueACd thtn herm
HIA khe Lalloa uuctuom Crtalus
YWw
thewn
Duzzet
Page
Date

tuwcthom oloesmet hawe


ac¬es aLqunal uaiallesattua

basameIAL) auo uOsk On the


alue sated
Lobies hL Tqumenf
Uh aLgLnal Cop
2CmauM

Excample
LLaosat

OLd tst Linti, intj


= 2:

LOLO maln O

=neuzale
int a- 15, bE 20 Þ
Susicm 0ut.brintln "belee Lall o 4ta
Suskm brintln 'betamt Call b u"+h)

uslemout brintln He lall a u a


Syslea aut antin Altea Lall b u+b

buzzet
Pago
Date:

Chaiacetucs o Call by Value


Oriainoalvalue counhot be chanqed

Called me-thod qets 6m a Cep


variable

3 A CQumeuL p mitie dauta tybe


CUh bagec
Jh ceby o angumeut value
m aut uwe d Kebaunate memr
LoCo 1om
Page
13 Date

Call by Belunence
ie.inattad
dE u&LdilkisCat mechanium uncem
baksing valu to he
a
Cngina
eug Callleda ALnce to
rmoa
vanable &AAd Huse he
ecemes 0rance acual
pas.aneBe
HuAL Hhe chm does he
pASasuelts
values rathe
Chtate Cepy o m9nal vaUL rodhe
Ounal alue heye.re
Dekswth trigidal olata aud buu
clhausaein he alue get ellecded
data hereporrth alestp
the

Chah atteishi.cs
Lhen theunchmik callacd in hepro9rumg
the values o ahualparametes ente
pasaAoAeLR
mal

i nu chanse poaMAtes a u t
Hhet heat pakeo 21CuPua

1 E Ued Lheh u Aaut th_chAmAehe


stote he ect.

vheachual pasalesi uhuh dhe_basseo


0 that_ hltec
Page
Date:
te

Ca by Vaulue Call u Renence


d Here he ma Heae mal paaumetes
pahauaAe ecieAN Hhe
olata Lm Otual panauee,
Hheocualpohabatkh
LChong.cs made n the L Changts made t the
rathe m o pahaotesa dn 0mmal pasamtes3
the actual te the Atote o
aaaseter Q uLa poramee

tunchn uPrimiieolata tube areh h dAt o


pagsed afven closs the ae
assed a arame tess

progYamns
22nLeal unchior Ovex loading
9 possible to oene uD rmoe
mehocl thin he Same Class ha
Ahancs he &ame mo me C Leng
there pCnCumeles oleclah.ohm a d een
hen Lh he case fhe thad
Hhe Oe &aid to b e oveLoded and he
prOcess L ccaned method OuClocading
Methsd OuAoadig L me h e
ALeAAe KLDAtz polum0rhusm

Whea
whenAu 0wsLoadeo mhod inueked
aAA UALA the abe 05 nLUmlLh_
whdhe Cre

DAAL Aded method ia alleolz Uhintto


buzzet
15 Page
Date:

the tub i n the numb


oh
o thhe
ameers he nuLsloaded mlnod may
Y
haue ditestnt

Eeamble -

Class abc

void addint xint4

um iatlx+y) addS,1o)
Sopln(Jhe
void add detuble 2 double y add (p

SoblnSumi ' (+y) addS 10 S,15:5

Voicd ada double 2, duble y dnublez

opln Sum i 24y +7

You might also like