JAVA Imp THEORY
JAVA Imp THEORY
handling MechanisM
ath daqam. WAP Code for. handling
one divided by zoo)exe Pyon handling .
1/0Lone
code:
CIOSS errorhandllng
Public Statre void main cstring argsc)
int a 10,
fnt b 5 ;
intc= 5:
try
C=a/b- );
iht y=a|(btc);
Syste M. Out Prrntern C"g="
+9),
hat is excoption 2 pescribe exaptonhmdi
diffevent
hou can you han d le
Denonstrate
typcs Of eycepti on sep tey
) ExoPti0n :
Cvet that disruptS the
An XCeption iS an CVent
ProqraM. I t is
is an
nomol flow: Of the
ulhich is throWh at runtime.
obJect
ExceptioTO| hand ing:
handing is c one of the PowerPul
kCeptona
hndle the untme Crrors. So thot
MchamisM to
the app/caton an be mainta
the noOrmal fow Gf
TYPes:
There are three tPes Gf ex cèPt1ona handling:
Dhecked ExcePtion
2)urchecKod ExcPtion
JEroT.
ch¥ed:
Ciasses hat Ihherits he "compile-time"cxo ption
Chec ke d ExcePtion
EL: IÊO EXaption, SQL CXCePtion, etc.
2)Checked CCeDtons Oe cheCKed at Cample-+ne
uncheKed:
ndling
t
)
The c lass ha+
excepton
nherits the RUn-time
uncheCked eXepti on.
EX: Athmetic eX
ceptin,Nuu POnter
Array LNde Out of Bounds exepton.etc.. excaptioh,
2)unchecked eKOPtiONS a e checked ot
'rUn-time?
3) Error
Error is Trre coVe rà ble.
Thheritance
Oihen One Ob JeCt cauives aL the oropertiS
bethavo of POent obJect i5 Knon as
INhertance.(It is ago kncCcon. ag Pasont-child ve latnshp)
It PrOvide co de re USabilit.
3)JOV Ihheritana i's the TMp PillaI of CopS
1on 4) It represert S the IS-4 rentonshiP.
TrPes:
) single Lhhitane
J Mubleve Ihhoitmee
JHrerarchicae Tnhottace
)MurHPe thhoitaTee
OHybrld Inhoitore .
Single Tnhemitone
Class A)
Murtileve);
C[aSS A
lnssc
maltiple:
JcassA |CIags B) HYbrid:
Hierarchican |cassc
COs3A|
CIOSD
CassB
Sdhat5
muttithr@ading in Java ? EY plain ha le
Cycle of a tocad ?hat the, Cldva
cOe the disaa
murtithreaing in 0va
Ang:
)mwti thread ngih TOva is o process 0p
Cxecutihng muitiPle threads SímurtoTecugM
2) hread is a bas ay light ueiqht Sub-Pro ag
Advantagsti:"
)IMproved Perfdhnare :,
Dts-adv.
) Comple kty.
9) ResponsivenesS
2)synchroni zotion
)Retter eSO Gie OVerhead
utilizotiÝn.
4)3t mpIfie d
3)ContXt 3eitching
4JtoKd to prdrct behal
mGde lt ng
) Unýted by hode.
5)pcoIateltsM.
File writoncta
Fle reder class
Hs (ed for (arttrg chooOC to)
eading
ad'pa choacto
dota froma file.
dcrta to afle,
)
2MOTk3
het ps,h,
19khich Featoe
destgnthg the CI aSs
the cas.
)bhetan co 'heps. in degiging
to cVeat e ah
2) whch eycord is uSed
Eyample.
A) The Ne Keyard
JCohichstatemont sh td be the fnSt
&tatemno nt in a a tova code?
A) hisc) or super C).
4)hot is the sgèficane f sUper koyord ?
Ex POtntb
A)toeliminate he confusion bw Super classes
aue motho de corth thesame
.
Su beasses that
name
Specfig:
defaut acek
Pubil
A) Prvaté
þrotcte defat
Prott,
T t iSvisble Defatt
Same POr ka Same CCkaay
SuciaS.
6)what docs 11S' stand for
desrgh prùnciple?
-sihgle TeS POnsibility Prncipe
o Oben-cIOsed
Pin le
L-LISKOV 3U bsytution.
I -Totefa Segre
D- qation
ependency
)nhich fearttoo
robust Code
A)EXCQPtonal Handing .
A) TO acheive abstOtior.
+LC5m)
yDfference 610 mothod oVerloading s cerridng
can EXCOteti
com Arite)
Cam do lete C)
16) hat isthe
is u5age f
A))Eha| Keyu
Finat (oy ord .
Key WOrd ih
+he ce1:
tava's Used tO vegtrt
o) I t cam be u Sedin momy Conte kt
)vavable
2mthod
3)cIag
11) wht |s TtofQre?
) t Used tos Pe CHy he behavioCO of c
CUSS.
Ss Shouid have
The PrthcPe States thOt "a ctos
Oy one teason to chomge. sahet meAg
e
CPOAststt
2) 0 : Cclassa
tho prtheiPles state s oPtwOO entttie
tes, priniAS,FUnctlons, etc.) Shoutd be
Modu
ctosSedfor Modifotion,
ORen for. CterSIOT, þUt
berereES.
4) I :
The Principe tat thot
clieot to TmPlemant do ot fae aTy
an
IrearaTt to the M". intotfco hich 5
-functioaly Proqronncng)'.
Cas
abstract
nantiate
higo-leveI
e 7the
orte Og)
abstratclag?
Can Shooing (strhgC)
ora newmaihe),
mainobTeCt=
on Naa) abstractim.
an
abstraet
class is Largge
Stat
that
ciThis
mau
Depend detals mair
tn Creatngan
PublcSStem-0ut.Prntn
dispyc)
vOA etendg
anguge
Cps
abstrat vod disaayc);
Gb.
not la tntonay
Cannot
eo
Pta statc
abstract
PNcPe
The |eg
shnoutd main
modure"InStantirte
or
A)+iding
KnoON abo
Pudc
3 Sy
ntax Cag
5)R What O
rs