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

Varada Java Module 04

The document discusses various aspects of Java programming, focusing on access modifiers, exception handling, and class structures. It provides examples of public and private classes, encapsulation, and the use of exceptions to manage errors in code. Additionally, it emphasizes the importance of proper package management and the handling of exceptions through custom exception classes.

Uploaded by

yashasvijay0
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)
5 views

Varada Java Module 04

The document discusses various aspects of Java programming, focusing on access modifiers, exception handling, and class structures. It provides examples of public and private classes, encapsulation, and the use of exceptions to manage errors in code. Additionally, it emphasizes the importance of proper package management and the handling of exceptions through custom exception classes.

Uploaded by

yashasvijay0
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/ 11

Module-t

aras Protertors ataflable


a. kxamoe leuelrofof
the nafos leuelt Coilable

and fonpleCa 'ons


o pa chages
Examples
Ans
ch'eo
heuel of Acces Prote

coNbio the Sam olas


eny encap&ulot
’ Aeces6lethe h hut leucl of Outsfeb the clas.
Ensuscs Sabolases or
GC Cesble
nlot

.Dyaut Same package


4cceu ble only thig leel.
to euen o
nlo
kyood 9utstle
ee package
aceueble hom
Sb claues.
Babelales lo
and
3. Potecteck Sane package
he
encapsulatoo and Prhntene
othur packog,
balanu beteen
Proules

Pubic
ohee
ACauiba utocton
meed to be
lowut Lauel aabes fhat
metho
Used
auailable globay
Gop ltcatoo 4eeus
Secuse Serltve kota
dota rorn Oohten ded
Biate
teul (omponanh, tniurg
: Ruticd otus to patkage

Pe-kcteol: Encous nge Cocle ole


by mttog omponnt
Qalabie -lo Scbolates

Publie Use A P?'s Rties mo mont

eral
(ample
|:clemo
1/ Package
dlemo:
package
naple f
Pubae clas fcceus k
Priuate

Protcfclllor 30;
Froh ted nt

Pubie Uotl showl) f

S0.P( Prokctc rotecteol G»2;


g.0.P( Pubhei

1| Package
lmpot clemo.fues krample :
Pabe Clas 7ut4ees eocfencls 4cuskrample
Jlate

qcesk ranple(o;
li00 Il4uhe

fop ( Beteted Vora ble

Bulld a Jaua oraton


peratua
Progam for a bantig Peton thie
h'on, 6oht a
to thnoo an
Cppli caton w
amount euen though helthe ha
colthdrous he cuton laajphon).
han mlolmum balane (otate

Arg
kxupton clar
17 utom
SraylcatBalanukrupho extencls Fruphon
Clas

1/ Mal clas

Publie clas
dosble Ma- 8Ak :5o0. 0;
Biate teutng sletie faal dooble

biuate dlouble balanu;


/ o n bucto enrte )
Cuba'c Bankla PCdoc ble faliaCiaa
intal Ba lane ;
thi. balance

Methoc to othdvoo mony


l
cofholrao (olou ble aman) hoes

irlet Balanu k xaphion


Cba lane -

tho Gll aent Balane kacphco"ro! hdrot


lenis belo i n t . "2:
balani

Il Man methocl
Pubhc Slatc man
Bankiq APp account Ban kug App C o00. 0
g.0.P C"Ent6al ba lane ' lo00. o"):

g.0. P C Tytng to olh. 00. .."2


aceocent. o8Bdraw

lo nothdrw oo.."):
account. coBUrao (aoo):
Gatch Ciuulftcient Ba lanu (/hows
Knaph'on e) f
}
kxupkon haliy nhont
Jauca
Lat

lontafns h'or

OCcsecd

when

hande unkm
kxupfor robut muckanin to
Pru'olu lacluctes
Jaua mechanim
Thi
fx cephons. be tukd or
block executed.
that hanclles he
Coole
blocl
coole hat /l/ pecut
block
an Cxaphor
Cath block

Caugkt hro an exuph'on


do cac lae tee
hroy mthod Can hron.
that a
tzupfons

1/ Blocte Cocle monior

Catch xcaptosypel er) 1


|| Bloce Cocl to hanclle fruphon

bloc le encts
I/ Block Gocle
Coo
claus Arpios Hot
Ribh'e Claus

lat data :
Solo:
ltfhhukekxaphon e) 5
?Catch tgnge)
Sop( hsthoehic kxophion onght:"
Cxew ecl. "):
block s
aloay
);

balane
to lrea te a pa ckage
H/ Butld a Jaua
4ccount Pgm
clars cofAS Balan e () methocl e
to QcCus method
lortaintg fo anothet Program
fmpot class.
4ccount
Pegrom
balonce:
|/ Patkge.
4ceount $
Publie clas balane;
doube
Psuale
(double baCane ) f
Publ (count lanu;
balanw ba
fhiy

):
+ balane
S.0.P(unnt balanu
votd Publie
Sound
l) make
Gnlral toctencls
Publ'c
make Notd etta abe
soundC2:
hnlna clas tract abs
1
KrGmple
trat abs he
las. c
lemen
by kd np bemut
es tub keyuoor abrtraf
cleclasd Abshact d
muthocl:
methool a S
eclartd that
pro'cle to
fo* late emp mOn lom a -
laese ptherC lanes cte
cAbrta
meant
arol
are Coetfenoleot be lo other
lareol cde {
s clan.
e bsfroct 'a he ustng inulanhatd
mut and
tamed Subc be Absta
ct l.
las C a sJaua Tnclas:
Cannot
be hal
&n ygcournt-
(); lane diplay
(500); qcount ACCount
clas Publ'c
{ lomma
fccounti (one. impot
ba
Sava /nalr
Clas
Vold

mao f
fube clas

CalC);
Ghtoral mycat
makeSoudl();
Soundi>:
Cat. no he

clateol
am spae
Ooole
goninahon anel
maklg
claskw and intolu. mere
clularty eater. ancl make Cocle
help auoid ramiag
Pockage Dcuuable.
mafdanable ancl

(ratig aTackage at te top yocr


de cla a package thot mat cheu tte pacRage
d Plau the

Sepl: Qeclane the package


Pa Chage balane:
Pube clas AmCunt f
Prsute doube brlanu;
batane)
Pabc 4ccount (doube
this. balonu : balane:
belonu):
S0P(" Cuncot Blanw:

qno-tlus potkage
Gnot

we Cao Qccus clates Po Ore Package om


the ?mpot Satement.
USfng
main
Pockaqe
impost balonu.Hccount;

4ceount (5000);
Aceount myAccount
Ycount. display Ba lanu();

th impot heycoond ktliaoed ay


and Clas. name
tle packag
4eeout;
Ex: lonpot balanu.
oildCancd impost Use the frmpot
and a eoilol
Card to om port
by the pa ckage
Glau lo Hee package
Ex: Pnpot brlana.
Bitl4 in hptios.(i)
Jaua's

Conclions
fxaphoonl
chack kxiphon bme
cheCkecd at comp,le
Qc tleu fruphor
kxuptons lo hanctle

Ghe Pog acd Catsnlol


foonl kutpf

xampl Go kxaphon

UhcheCked kxuphon Comple f'me brt


20t Chetked at

ghie urn ne. to ha dle


athes at
mamer
The Prgg

Exipfon
.(t)
harcled
nat
hat cne
Unvought xupibns an Exaphonstho temera bon the
to
cocle
9thi the uncaught tcepbo that clucnbs
shen an trale
Program Cove tho exepton
ancl
Hhu locat'on

Enampe
ample f
ncoug htk
Puble claus
Pubc sfati

&.0.P lrumbes ls3):


tHoco do 'xtpton clau 9
Explafo ce th Pgnm
Ang
Glas
Stept: Chcate a Cueton fxce ptioo
extendds ExapKon
Publie claus My uutom(x«pton
Cutomkxtuptfon (sthig msoge)i
Pubhe my
SuperlmeMage ):

Stpa: (Use th Cutom fxupton n a Progrom


Publie clas lwtomlxupnXample i
niskeyMethod (at alu? troes
Pable nofd

(raue <o) ?
Uaw not
allow:+ Velu):

80-PC"aue S:+ kle):

angs)i
oo kample (xample new
Cutomkxup
trampl1. nskayrthod (-5);
( ycustomkxupfo e) $ egetnanage®c)
f Catch Caught:'+
Sop(auton fupphto

You might also like