Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

OEXPlain Excep tiona.

handling MechanisM
ath daqam. WAP Code for. handling
one divided by zoo)exe Pyon handling .
1/0Lone

A) e ptinai nan dling:


Exceptional handling is amechaniM to handie
run tiMe rrors So that the ornai flo0
c-the apPlicatton an be maintained.

code:
CIOSS errorhandllng
Public Statre void main cstring argsc)

int a 10,
fnt b 5 ;
intc= 5:
try
C=a/b- );

atch (EXce ption )


OYStem:out.Printn CDeSGn Dy Zeo):

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.

t Ex; ot Gf memory Error, virtual mac hine Error,


ntane ASsertion Error etc..

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

5) murtrocessing 'and muti threading both e


tused tO. achieve multiaskin.
A)TOVa multtnr 0s mo Sty USed ih games
Animation. etc
)A thread goes throug h veuOUS Stages inits
Ife cqcle.
cOe5threcÚdistates
2) Thae ce in Javai
) New State
i)4ctNe state
i)B0cKed stote
\)Timed stote
VTerm1nated gtate
3)Lee Cve of athread isContiol ed by JVM.

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,

Rea ds the contersts 2Aritg h


a file. aa

TNt SteaM CtPut Sfream


rea der Clas writocag
t. ts uged for 1) t is used for
readig bytes from 15 Writng,: chasactoy -to
néort P t s t r o t
net Stream

)onverts astream of 2) Coverts a gtream


bytes_Intoa streamof Chmactoag nto a
Choggtes. stream of byt.
nPut Strecm
utPutStrea
) t iS Used for
Veadtng bencou dqta )Tt Îs ued tor
as a Strean of birte. Mirthng bnoy data
of bytg.
) provideS mothod fo
yeadang byteg fromhe Providog me hod for
LArtting bytes to a
degtinati n.
r3vte streamayte stream
)4Cand ie ra binaxylv: ) Handte chooactsca
data Ih the form of
tn eho form af
bytts
chooctog
NIt iS SUrtablefor
D) Tt s specy dagrqru
VEadng qtrtng for reading
non-tetua/ ritrg
t e t a data

SCfeed readon dog Bffesod certo clag


Dt iS USed for DC Tt (S Used -f6r
readeng tevtfProma urttng txt to a
choact-inPt sram. chosiaoter gUtPut
) Tt wraps oCund
Stream.
anoth1 ROOdn eo It wSiaps d
tha NPt a3)y'anotto Curtto1 buffg the
i:Guteut

)
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)whiCh I DtetO ih Tara holp create


threads'
A) RUnable Ihterfaco"

a) De-fne abstrcct CIQsS with an vam ple


A).The Proceas, of hiding uncoanted dotois
of database froy the erd usO,

(0) hat is the p oROSe of an Thtorface in

A) TO acheive abstOtior.
+LC5m)
yDfference 610 mothod oVerloading s cerridng

A), overadg overrtdeng


)It is compile-te
POMmophsm pomorehism.

YtoÇsy wHhina 2)It Curs 6(w tuo


ClageS,

8)rnag not reqeise ) rege nhtmp


4nhe ta ne.
4) Statio bindinY 4) Dynamic bnding s
used in verrdn
over odin. 5)Tt gVg bettn
5) 1t \veg PO
Prvate ime metno
PestfomamR
SPrilote fina Conbe ove rridden
an be Cyer I0adad
defoutt ibroy ot Ova ? LIst
2) uhat l's th
fove feactDUY
) Toa Standa
Stonda1d ltby.
Fea tt
Simple
Robut
DYomnic
hMurti threaded.
inlPl
t3) DiPexoha G Thtrare Clag

yuhat (s Shadow Voyable1


A)0Co01s hen avoabie (h an
do otased with the Same hamag a
\Wasiable th he GUtoi OPe
1)
Caphan a loÈA ble etaed wth an a.CoTteiy
So be has the $amename ag a VOabe
dealasud
15) what 6S the p OPOS e op le ag? LAt
CUny ye mestho dk of file ctas
A) IH s Uged tor
file
Creaton ofble c derectov e,
seaheg, fle deeton ete
metto: .

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.

twhy matiple, Inhoutamee t5 ot POsÍbte cn


rva?
A) TOVa Compile canott decide CohiCh
spa muthod it Shouid Inhoait

(9)Listahyfve cass ef taUa o pacKoqe


A) )Effered Nptt $treom
ARFered outPit Stram.
n) Buffered Raodo)
V) Buffou d rit:
Y)ÆNRT0t staM
viQtt st veaM,
aO)talhat (s the use ef Supen Ikeycuord?

SQPereWOr d can be epd to refo Lmmedice


Posent Clag obgect
)QPO keyord can he cged totnvoke
nmecat e pcoent Clag metho
) upen C) com he uAed to ThvoKeTM modqte
Pawo nt Clag
ciasg cengtructO).
SOLTD Principle
J Thu Solic i tAIaS IOtrO due by
priniple
RObertt C.Mrtim.
I t is a mo
Q)Tt is ag UnCLe ROb

Coding Stamdard InprogNamin.


The solid ocronyM Stan dg for; wha
Inst
SSeingle Reaonsiblity Princeple CSRP)
Syr
O- Open/ctosed Principte (OCP)
LL'skO substitrtHn PrincipeCLSP) A)+
Segregatin prnd PltTSP).
ITNteface
D- berendenay TOVersion Printple CDTp).

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

no PrinciPe Stte hat D e t e p Chtld cl QsS


Must be substitutabe for thon
- Classes . ttie PriAePte-enscbg ht py
Parunt
ciaSSthát she edofapeet clat Shotyd

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

You might also like