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

java assignment

The document discusses key concepts in Java programming, including the differences between abstract classes and interfaces, exception handling with 'throw' and 'throws', and the use of the 'final' keyword. It provides examples to illustrate these concepts and explains the functionality of mouse event handling in Java. Additionally, it covers the importance of cleanup methods in resource management.

Uploaded by

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

java assignment

The document discusses key concepts in Java programming, including the differences between abstract classes and interfaces, exception handling with 'throw' and 'throws', and the use of the 'final' keyword. It provides examples to illustrate these concepts and explains the functionality of mouse event handling in Java. Additionally, it covers the importance of cleanup methods in resource management.

Uploaded by

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

2/510006

JAVA ASSIGNMENNT
Kashis h Maoda
Le 1- Waite he diheene betwen Abstract clas a d
iuterfae.
Aws ABSTRACI CLASS INTEREACE
1tdos net Aupport multt ple t f u l l y cuppoat mutiple
Tnheitamte. Tnheitauce
t san Auoe fal, non-jihet I t can luaut only state
Atatic amd non-tadic vasiables aud tnal vaniabl2.

The Rbstroct Ky word is wd| The fnkeshase keguood i


to cleclae Abstast clan used _dtamate Tntuface.

c a n uave wlas wentbes Menbens ens effnkerpace


Mke pulyate, pmatectid ete ne public byoefault

6Au Abact Las cam 6 An interkace cam exteud


eKtud anothe Jawa elaM Mothes Jano fnteace
and p liment Java
aces

Exanple: ( Exaeple:
hublic abstAact clan bublfc 4teyace
Shapes dsawable
mblic asanct vod. yoid drausOj
dnauus ();-

Quu2 WMte d eene bebwlem mow Oma maus


Keyword ppoat ith am exaNpla

2T.0
THROW THROWS
Java Twnow Kuywand &wd It Mud Iy
to thhown am extcepho n method
ExPu CITLY fu he tode
ALinaune to dbedase an
etceptiom whleh migat
be trown by
block ode uudieu
dusing etebahn of-code
the
St cam
opogale mchecked Using thou we cam
excephiens delae
both checka_and _wuchueked
Srllowed bs OL gTt exceptuousy
wtaee o Excephon to a M oh talloused yelau-
be un. Exzptins to
be thoM:
A witin the 9 t i ed with Metod
tihod.
Aaratine

EXAMPLE OF THRON EXAMPLE OE THROws


public elau Tet Thow
public dlaa 1et1tous
hublic static void CMm
aw(in
hlm ublir shatic atdinideN
(i'ntmyintn) Huos.
fhow new AuthmeiiErephn
aRthmebte EXcephian
fntdik Mn;-
No Maative" Rlu di
hublle stnte vetd
else aa (Shayausl
Sstm:oulpinttn(g nn't TastTuou5 ohj-n
TekThiou
whi Shatie_void man (Smi[Ia44s) Ssfmout.pundn
Tut Teaw sb new 1it Thaow();
ob tnum-3)-11- tten hltmaickxtsptm
OuLB: Wadt atterene between
withwith EXampls nal, ffralie ond fualy
FNAL
0 Final ky word ad
ouccesu waditen Ae to aPply
estitiens on las, metlhod
A wed wit clawea, s Vsuable.
(3) a) 0Mte declaneel blomeMMethds Amd varuable.
b_modsked. venstomt Qud taoE
b) al Mdhd tannot be
C) inol l a cannot be ovAI'den by ubeus
() Fml Method Mherilid
exiuted Only wheu we callzt
EXAMPLE-_blic as FinalEgTest
iral Int hge11;
void dipay O
age sy
publa ttate bod aaSig ay)
Fihal E Teytnu FihalFq
TejHO;

HNALLY
1 a blouk fu exeph en tenouing iu Iaua_t
olual wh
fmpotamt_toole_otethe excephin uu
Th aways pelatd p ty ud catelu fn
Hlandlig 0 reepho
a) k hms inpetant
cadeeueu er cepizen Ocewnd
bnally block_cleans up all stuousces wed in
lock.
t x u l as Lopn t cotdn block & buing
as
ereub Tts exeutin Y's
fndepwdsnt of the xupa
ExAMPLE: puli las Firally Eg
ublte siahilkd rauin (Shmiy£Iaaa)
ystivn-ud printdn "Jnsidebr
nt data 2t)o
ystn 0upaintta daa)j
tin pithyelkc Extephanea
yplim:Buk println/EXcLpton
Cfuuudshully
Uysjm.dut printl

ially
ysin cut friutln Munys exeuli

FINAUZE
Mehod to cleam up uat bejoe obydt
ganbegt tottroted

a) perfenns laudrg mtirines dojeitbHore


desbuchiw
Exeuutad yúst behoa btär à dutreyed

EXAMPLE
pukie clas Ffhalbe bxanple
publie Jtalit vold man (ting I ag4)

fihalize Examyple obj- 0w FinalizcbrampleC)j


/ unling hashccde
dystm oht. pritta ( "Hasheode i t ob:haskund:0
Ssje. 9();//calling 9athege collector
S n -oäl.pisthn fu Endf gastogitallecio

/delining Hhe tinalize Mthed


brutect4 veid puializel)
Bystin.0uprintla ( tallua fialze )method

ue:) WAP t o Ceale a amme MAAg AWT. wplment


Mewae Chthaol ) Me Ententd C) aud mewsezi teal)
eaubh C u hat
mouse entes it
a) Sie 4 wmt henld lu tuplld wen
b) Faame JMould Aouce to oniglralL K2e whon Mouse
y ln it
A.
C) Close ame wen MoUse ekik inpojaun-ast
inpést fua utl *3 ipont java aut.euert
ublit das G8 exteols Hame

addMouselistene newMy Mense Adaptois));


add MeweMOtenliîtuws(no My Mowse hdapleslthi))3
ad Wirdowlistune(hur Mewirdow.hdlapre()
able void paiodt [(aphasg)
9.cbaulhag(mg, 20,90);
nublki Jbat voi'd maun ( Shuiy(J as)
G8 appwi'n n w Qe);/
E

appwih. se-Sizen p'mersjon (200,200).


Do)
aspoin:sek Vir'bie (Tue)
dau MyMoweAdaphe extuds Mouse AdaypteL

public clas MyMouseAdapter/Q8 ne)


Hai duo =demo

ubli void mouse Cucked /NowEEeut mel


deup ms Mouue Cuickadl;
demo Set.ize(nuw Dmeustoy/200,200)}
demo-hupamtC); .

uublic veid maue Enteud (Mouuebient


m)
demo Msg Mouse Entead
demo-setSie (neuo DimensiancoöLoo))j-
domo Aepaunt();-
wblit yoid mouse £xited (Mouse
Erent me)
do nuUg:Mouse Extfed"
duuo setS1sible/fale)
duuo. Aopaimt [)
clos My idawhdapau exkonds Whdo Adapter
ublic verd wndewllosira ( windowEvent me)
Syskm.Cxit (o)
uestion 4
QUTPUT-
ACommand Prompt -jave C2
CMD
ndpversion 1049844 766)
(cgspft osporation ight resered
seritsruoEMcd
WsersistuDENTDeskto

Users tsroeNT Desktop1avO8

Mouse Ente
ereo

MOUSE ENTERED

Mouse Clicked MOUSE CuckEp

KASHISH MADAN

You might also like