0 ratings0% found this document useful (0 votes) 2 views8 pagesjava assignment
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
2
o
*
J Explain delegation event enodel with example: :
‘pth delegation event model handles eyent- driven proytarnmiing with
———_—_— EE —————_$§_$_ $1
So System: pus pineus (evwor + © getmcesaac’) 1) aaa
z a3 3
Sad Rinatty blocs «
"THE Hinaly blocs is always cxeaited 9
exception oY MOt-
EX Class mMaini
putlic static Void main (StringlI a1gs> i
ape
Int vegutt = 1012; 4
Syste. outs PTIN#LS C4 ResuLe® si YesULED j |
Veaten (Arithmetic exceptions) £
System: out: printly L"er107:" + ee gek messages
4 Hay §
Sy stern, Oud! Print (" Finally block atwoays executes "9;
193
Sth sOW and throws 4eyv90%d *
s The “throw Hey uso!d 1S used to explicttly tow a single excestion.
9 matter whethtt AHEIE Is an
public static votd main ¢ Stringed args) £
int age>-53
tg Cage cod i
th1Ow NES TLlegotmgurcent Exception (“Age cannot be negative");
a4.
€x plain Sting handing functions 1 a
Je CharAt (1 Tt TetUrMs a character at a specified position.
s eqrath (2.4 Pt compares the tuoo given strings and 7etuing o
Booktan, that Is True oF False.
+ Conca 62: Appends one String tothe end of another.
+ Length (2+ Returns the length o% ao specified eting-
» to Lowes Case): Converts he String to Lowercase Letters... }
+ Lo Uppty Care crt Converts the String to uppercase Letters. "
+ Index of CP! REturPs the fist found positon of a character. 1
« Substring (7! Extracts the Substing based on tndex values,
passed ak an aygurnent-
b
three compontnts & event Source, event abfect and event Usterney
The event source generates events and registers Listeners. Event
oRJects cary event data + Event Usteners respond to events ley )
rtja Implernenting specific tater Faces and tecelving vy
% Ext: froport fava-util> Event object 5
Gvent Listened;
ent Ogject 2
=
fen port Java. utl+
class My Event ev tends EV
my event (Object source , string ene ssoge) 1
Super CSOUrCe);
Ariss eneSSAge 2 HESSAAES
private String mts soges
Sting germessagecy 4
OLLI 0580965
17
ingexvface My Event Usternes ex tends tvent Listened 4
void onmysvent Cy Evert went);
clams Event source £
private MyEvent Listener Umsteneri
void addEventstenes (My Event istenes) £
this. Listener = Ustent 5
void dosomethingO) §
wD E e
Ustener: ony event Covent)
yaa
Myguert events news MysYENt Cthis, Meustom event escured *)/
if Clistenes |= wiicewia as
class myUistney tenplements My Event istener f
public void on My Evert (My Eved © wert) Z
SyStem- puts printlo (* Received 4” + duet « get message ¢ 3
| ah cla Retegation Eventroodet £
pole Gaeie vom en Cee hate ange) t
EventSource Source = new Gyerst Source OF}
Sources gad Event Lstenet (M9 mytseental) 7
Source - dosometing 6); ’
G4
ce)
Define an evertt » Explain ushak axe the event ames & Cvent Usteneys
vent © ‘ ‘
Y An went ts a Spedifle occuvance 01 action during program
‘ecution, after assovioted with user (nttrfestoctiens oF SYstern
events. & x ‘
vents ave handed urtng event Listeners +0 Yebpond to /GAG proces acre occ UTTENCed*
Event clames i
mae Event Carsca ave custwor ¢
Object’ ov a subctas Ube ‘Javaro
sEventOKje ct,
Pothey represent Specific types mh eres and hotd releavent dat
ist nee
the event, ion n be Usted bi went US!
‘series i uk When aNd UshEeTe the
PUPAE COaes encopsuiate inforrnoten ge” i
A ethods to acces thir data.
event occurred, and of en include mn
extend ‘Jova- util Event
tamer thot
pee AW Tevent! oF \JanaX-Swing eve.
2s Event Ustenens »-
BR ixteniens ane loterfaces-01 loshee Pies ae he Necessary
articuloy type:
methods to7vespond +o events wh a Pp
+ they, Implement methods Ube Jactien Performed! for ABenUstners, +
Crnoure cUiclbed’ for enourse Ub tenets » OF ConMyEvent' for custoro wot: ;
+ Event Listeners register with event source Ceg, wuttons , components} {
to tecetue and handle events mH inteyert- }
Slexplain au the AWIT components Lith eKarnples ?
fel. Window | This is top-level wntainey and an Instance Bp window
claws thot does not ‘contain a bore ox a ti tle
+ Fxarne t- Frame is a window clans Child ond comprises the ttle bars
border and menu bats: : i
Button !- This is ured +0 crcake o button OF thtuser Interface with
0 Specified Loto We Can dexign Code to execute sorne Logic on tht
cuch event ef a button using Ustenes-
fe Text Fields 1 this components Bp Java AWIT cveates a text box 8b &
eingle Une to enter text data- “ 5 "
l- nabelt- this creates a rnulki-Uine descriptive String that ts 5)
on the qraphicar user loterfoce- ”
vost This generally signifies an oweo that allows’ you-to ova.
Gaps oa graphical .Uker tAterface
SB 1ée & This, ~ePTEMDE RIPE aor oto. Fading rillttpie cbteek hs
Gption ushich the uber sekects 1S displayed 0740p of the MmenKL. i
geecrot Bor TIS 1S UbED 01 prOViding Hovzontal oy Verttcat
Scrolling feature on the Gor
ais dan Hold a Wet op text Mems. Thi6 cornponent attows YY
ont of rove Options Fomatt availavte a
je Ca.n)
cg
la. st
a user to Choose
4 options fn he Ust-S used to Create a Checkbox
womne hb
id main cstntogls ange) 1
oe
strotic vol
Frame © No frame C"AWT fore“ DF
tomes ave anianged in thé 401 fowns bby determ
J positi0e oh Com ponents gorthin tht: contoinet
Lyrheve are 6 typedep Ayour oder aay Lede
Cormponents ay
4o- right order The wrap 40 “th
You can eonbel, gaps and abig
components ave placed
pooy get thet pw
be Flow LaxyOut =
pees nment-
las Border Layout +
ep the containe They
ov centre
along ont dimension:
eqaid Layout F components are orIanged in equauy - Sized Ces iD
ie ed Opt EO Oo me ces
eft — tr -vig!
ents are compler g
a auigomets 1m
a grids fitting |
be Grid Bog Wayout © comm ROr
ent cell etee = ue
differ
watio, aneccting Che + am :
ee Box Laxyour + priange comporere® sithen verti catty eee]
} with BANE mating thern tquat to the largest io
| pak airnension: "
ees layout Stachs Cormponents no clech with only the top one
tehing wetween different views oF
isable . pts used sor sul
Ee oa
{her Checked 61 Unchecked °h SUT ashose>
txarople Bf Fiarne Cornpone
Atle AW
ns eveagtiernles ide sent Mitt taste SR RE eat
00.967 + Explain al tht types Out manag
gets enale ur to hee the oa BY |
xy 19 whieh visuot | |
ing the Size|
© arranged fo. a top-to-bottom, teft-
e next Une Uf the container isn't wide
ot the top Proottora left wright
egerved SIZE
aid waned slewing
aintaining O8 pects:
4, .
Sh Explain thread Ute cycle With éxarnplet
E ‘
A Thread co through various stages tn its Ufecy ete For €xarnpl
atnread iS born, started , tung, and 7heo Aith. the ces A 4
oy
thitad-
\diagrarn shows -ne cormplete Life cycle Bh %
5+ Runnatoler the thread ts actively (kecuting 1t MOwbS
e Waiting! The thread voattt for another thicad to bignat
tt +0 continue:
+ Timed waiting e the thiead 16 woiting
Intervat oy went-
we toro Specified time
* Terminated (Mead): “the thread Hox dornpleted ts tark o7
Herrninated +
horite the difference wetoeen routtitarbing and route! threading?
_ Muttttarbing
\- USeYS ave allowed to perform
many tasks ey CPO
la. Pt trvolves OFtem Cpu switching
letorN the tarhs-
githe Processes Share Separate
rmecnory:
lu the components Involes {h rout!
processing:
gthe CPO IS pIOVided im order
to execute many tashsat a
iene.
b-2Pt is Slowey Cormpared ao
moult? toring. $
Muti threading
le Many threads a4 Created Homo.
Process through Which cornpusey
power 16 increarta:
a cPo suitenthg ie BF \nooliea |
wetween the thread ¢-
B.the processes ave allocated
> the GAME Memory:
Ur ThE Components does not involve
fo mutttproeessing:
A cpU is provided (A Biter ee
execute threads grorn
PHOCESS at a ~LIere.
gi while ft TS faster.
Hs Tt HELPS Im devploping epficent|
6 piograres
[U Tt Welps in developing efficent
° system.——
2 Z a
- Explain Applet Ufe Cycle us
jowa ts A gmat, 19 tt1Ccat. yh amp
aun within web ‘vetiged any Fre
wedded 10 Wlb Pages tor mete
. 1 hase,
am, HEPINE Applet
AnD applet io
)| gaa clerigned +0
various tashs and is emb'
tent +
a)
Wtb- barked wn
iige cycle of APPL
Fentet method
J
a
cena) eae alae
paint) method
hat oat 4 oe wae
EX frnport java - owt o*5
Import Jova- at: applet + %
public class Applet! extends ppplet >
ola tate). es.
i pubic v
ser Backgr0urd Color blACK Yj
Set Foreground Color. yeltow);
ene:
4 ;
puttic void paint (qrophics gq) —
yoo 1009} e
Z. ‘ 5 ye a
gq drawstring (% welcome",
B
4
explain types
qnere are two TYP % ere
ReGen Torok applet te tyPicany ©
network Locolien +
ded permissions socat appt
iron met
7
examples -
| Haye OnE they ove!
xeeuted fromm the
Pt doesnt
eh —ppplets volt
\ bocak apple
tocol file syskrm oF o trusttd
peqpaye network access oY eKten:
are unsigned and they can uo ina contoiled env