You are on page 1of 6

ADITYA DEGREE cOLLEGE

Practend o o
Packagc (Ctecution)
Tova Pograrn execution of Packo
bwvite o
Oim

lgo tho

SteP OYite a Java Code

he Java Code
Compile
Step
he .h file.
coea
Step
Native method implernentation
y Wite he
Step

Shared JibNOny.
Cre
Create
SteP

Run +he Paoqram.


Step
Page No s
ADITYA DEGREE CoLLEGE
Date 3-23
Practical No o8

Program*

import Pfist
ctass Second

Public Static roid ain CStving ags ta)

fYst a =neD first )

adisplay c)

Outpuut

first Package
ADITYA DEGREE GOLLEGE
Dte ( 3 33

Exception Handling
Aim Ovite a Java PYogram Ho dernonstvote xception

Handlin9

lgovl4hm

Stort
Step
equived System
defined
PackageS
import
Step Co
C on
nttaa
iOi nS
s
tohich
ExceptionDemO
aclass
C v e a t e

3
Step method
main
Scanner class
an
Object for
Cveote

SteP n.i,d
5, 0,i,d
Size 5,
a
aYr oith
oHh Size
Delare
an aYYay
5
SteP
Cveate aty block
6 of elementS into
Step
Reod nValue number

step
orYau.
Oh zero and epeat Step-9
Initialize
8
Step until i20

into ar Ci3
element
d an
a

denominatoYintod
ead

Step

DEPARTMENT OF COMPUTER S
ADITYA DEGREE COLLEGE

Pratieal o 69

wlh zevo ond ePeat Step 1


Step
Step t initialize
until 0

Print and erd try


and
Calculale aYY Ci3d
Step
block

blbCk o Catch
a Catch
Cveate
13
Step AYayTndexOut of BoundSEXception.

Catch
catch
a Catch block+o
Cveate

Step ArthmeticE Xcept ion.

Stop.
15
Step
ADITYA DEGREE COLLEGE

Pratel o

ogvom
impovt Java.io.
impoYt Java.lang *
*
impoYt Java util
class ExceptionDeno

Public Static Void main (Stving orgs ti)

Scanner Se ned Scanner C Sustem in)


int oY C?1 = neD int t5)

int i d y
try
CHouo many numbers ou ant:)5
System.Out, PrintlO
n-S.nextInt C)>
Entey Elements : ),
System.out. Printin
for Ci-0 ieny it +)

avY Ci S.nextLnt C)

3
C Enter denorninatoy:
/System.out.Printio

aS.nextTntC)

3ystem.out.PrintLn C' DIVISION TS"),


for Ci:0 íenyi+t)

System-but.Printin (avv Ci1 + | + d t + Cam ci1ld);

DEPARTMENT OF COMPUTER SC
ADITYA DEGREE COLLEGE

Exception e)
Cotch(protrdeioutpfBourds
Ranoe
Sysien out.Printin CBrray
out

Exception e)
Catch (Prhmetic

zerO ETTOY
Divided by
Sustem-Dut PrintinC

outPut
numbers you ont 3
Ho ran
mony
10 20 30
Enter element
denominator5
Enter

DNISION IS

to
2015
30/5 6

You might also like