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

Oope 9 Obien:: Main)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Oope 9 Obien:: Main)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Assionment

Aste Java PoOqnam on each concept of


Oope 9
oh obien: ard closs
A Pronom
ctasesSludet

sing nome "'madhu

pobic stale votd main (sl»ingt1avg)

stutent Si-new
stodent ) 1/Coealtngon
okjec of shuden
Syeem. oulprintIn (st.id)
Syslem.oul Prinln (s1 name)
int age e 30
s l i branchcse
Syslem Oul poinlin"yoor 0ge is: "+age)

Syslem ool println("jaos branh is "tbrand


Op Java sludent java
dava student
owRNo s s 2
nOme s madhd
Ho0r
yoU 0ge is: 30
is: cse
yoUY bra nth
Progpam on
inhesttance
injava
Class Employee

fnd Sala7y+00

closs Pooqsorne £xendsEmployee

tnt bonos- looO


Public slatie void main(stnqt]args)

Tooqs0rmmer P neo Programmes);

Syslern. ool Pintn programmes Salaryis


P.sal
Syslan oot prinlnBenes of
podmmer is
4p. bones
oulpot Javae Poogrommex yaua
dava Pr0rommer

Prograrme dara is: Ooo


is; 1000
Bonus of pogammer
Fo0gam on 0bstsac 4on
abstsact class B:ke
ela
a b s t r o c t void o o n C )

Ezlends B:ke
closs+Honda +

void runC)

Syslem. oul printin (unning safel")

Fublic stalie
votd ma?n(stzingtig)
Hondal+);
Bke obj neu
Ob.oun C)
Output JavacHondajava
Jova Honda
unning sately
Toogram o n encapsolation
Package mypack
Poblie class simple

Publre s talie vofd main (stzing [Iaa)


to package)
System out Println C'welcome

Out Rl davae -d. Simplo Java


Java hmypack Simple
weltome to Pîc kage
F0go0m on Po eP2

Class Vehicle

votd sunC)

Ssystem OUt Point ln(vehie le fs zunnng

Class Bike 2 Eztends vehiele

void onc)

System outPaintnCBike tsunning safely');


ubie stake votd rnain (s4ng agsty
Be 2 O5 nes
=
Bikezc);
Obj 7on s

OUtpUt lavae Bker-Java


dava Bke 2
B:ke is sonning9 sael.
hot aze vartables?
2 localion,in tha
i s a nam.e of memoy
Arvosto ble sore the. valye foo the os4iGs
able t o
we can

VOrioble naMe
a P 7 0 9 r a m ,

where z 1s
nt z =
1O 1/
Ex
on
i s nlertace?
wpile a program
bwhot
indexface? of methods, which
is a collec-ion
AIntesface;-1

and
abstoact by de faut
ape poblie

Proqramr
inlesfoce calinteoface

int Odd Cinto, inth


n t Sob (inta,in4 b)

alcolafo Implements calntes face


Class

Public int add (inta, intb)

7etom atb

Rblic int sob(tnta, íntb)

Detusn - b j

PUblie nt slate void main(stoing ogs 3

Calculator Cal = neus calcula-fo C)

Stem OUt point In valué ogler addihon="tal, add


Slem.ootprintndve ote 6obstacan-" ca subls, )

OutPytr Javae calolatoo )ava


dava Calcwla-toz
atue ale a.ddiiane
vajue after sobstracio 3
3.mhat 1sPackage t Explabn steps for atking
Uses defined Packoge Menton -yes of po

A POck0ge s 0ooup of elas Se S, Inesfaces a.1

Sob pockoe
Ypes of Facka
BuH-in pockage
Uses defncd puckage
user defied pockoge
Steps fos Csockrg
. 3sst czeate a disectoy within narne a
Fock0e
2.Cseale a java :le in neuy Crealed d:redor

3 Tn tava l e yoU must Spectt the packoje


name with the help 0 packoge.
with Same name of pRUblie das.
4sove this Pile
cldss in a Can
one Poogom
Nole- only
declore as poblie
5 Nou HO Can s e this pack0ge in o T

am.
whot an tzepton ezplain pe af
Ezceplion
Azcep ton hand ing is one o? 4he pxwef
handle t h e runtime eorors So
mechanism t o
he oPplicotion Can be
nomal floco of
hat
ma'ntained.

Checked ExceptionA checked Excepbon 1s o


Ercepbon t h a t OCcurS at the Comple hne, thete
ase also called as Cample tme Exceptons These

Enupions Canrot Simply be ignored at the imt


0f Conrlakon, the proaam Shoud take coxe ef

hese Excepkons.
Unchecked
n
aceptionExceplioni-An
that
occ unchected
hese a e also called at the 4ime exceptions
at eeatin
a s kKuntime
mclude T dmmina buS, Such os
Exception, these
impopes Use o}
logte essos so
Ap1. Von-time xceplions av
gnore d a the fime ol Ezceplians
comp:lalion.
00SThese ase not ereeplions at all, but
Poobems thal 0sise beyend -lhe corsol of 4he
User OD the ooa6amme Eoso defnes
Pooblens thal oe not
Ezcepled ba POamm

You might also like