Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views

java assignment 3,4

cse
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
0% found this document useful (0 votes)
16 views

java assignment 3,4

cse
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
You are on page 1/ 20
ogfi)2004 ASSIGNMENT NOs- 3 a= quees| pate ony —metnd of aby ists a ie a ist vith_th lox Ans, || Methods of —_anay. tisd__elass__w ely ¥ ejlax me | + Retin ype :- boolean _/ voll - Syntax :- boolean _adel_Celement); __ a g.adel Cin index, element)- + Insents _an_etemenlg __at the Spectfieel_index + Retuw_type_+ wale) —~synlaxs Noid adel Cint_index, element); Sreenleaee “he element _at_the specified ‘dex. + Retina ‘ype: f Céenenic_type a E 2 Syphax get Cint_index) ;— ~get0- 2 : 7 _ + Replace the element al pecifiecl pasion 7 + Retin type + £ : + Synlax:__£ set Cint_inde £ “elements = e 5 Sat - e oe > Smt the list — — = + Retuyn type: void ; + syntax: J void svt O. SS Que- 2! -s a= Saye [How yo deckne ond ‘cece on nai. dova @_ = sw to poss on —ariay_to_me anetine—2oxpain. “aly Suitable example - ~ = ANS —~__ ‘ item Sol oF simile typeof ed dara__ element. Stor aaa! location. ‘Deglare_orrvay.+ jot} my —Aavony.j : Seale —amays ny = “new _int L153 — ink a roy — Any = hem inky + puss j—tMay_Fo_methaclg____ —— + Thou ora —_Cup_be _pugsecl__Lo_metincds just ___ ke ~ other objects a _— saimitve data _ty pet + (hen __yo\__pass_n_amr-cly_ba_o,_meet Ho\l_qie actually pass ing reference te _arvay. = +The __synlox fey —pussing —an_cmay_{s_the ame _—ol_puising 0 Simple _yowiable. bur_you must define __the _méthada ba. v.decepk om “i ANA OS __q__penamebeny. i he pnp -ofpaseltg_on__anay_i et i hansfery Inyo _cimaunt “oF data ate ne “examples frie cass Testhmay [ cystemcul-minkin fon Li} 2" "5; a es ee : 5 EE Hubli _stciic wold rain (Shing) ngs) _ : re i ink) Any fino 80.40.5045; : teplou Sy ne 7 Gy Fray ny AToy. Ee 7 3 : glo, Anau elemenKk me: : = Wo 94 30 40 50 —_ + « explana mi: ) method accents _an_omay : 5 pmameter- ae in mot . .an_aayay _muAnay ig created and same values. * 7 - Theory ic patsed to display Ana, methsd z - wou can __be ty yethad s the = Some sway _cS yarlables- = nr ns 0" uy do_yoy declan end Ques) Hhals- — an Amayt an * —tnittallze—~ an__array— In_javel —- ana D of similay type oF . An _aniayi¢ a gvoup__6 rn elements ined in cantina es memati + Declare AMON 4 int in ee + Initialize 1 Jove _iniliaiee aay. ig rletly a don_tbed fon intHalizing on angi an ——_——_. omy Rey ae : = a 2 A I I Leta! . ~ T public stale Nolel_nnatn {shiny (}-avgs) | | | | any (j= New “int 5}; eectaratiien & inskalfalten = Oy Lol = 10; — for Cink { — syste: -oul- pvine nancy iD i — falp, 1090 10 f Homtength ie) (Qh = “What ave the disodvartoges of Array 2° “| A fixed Size: Once amay TS eveaiedt, It3 sve cannat be changed - The. \rmits Mexibitily IF i reed _ to add ov Yemave elements dytemt éall | 9. Wasted Mermen y r IP you allécate an array _ with mae__space _lhan needect. fk may wast memory on othe hand, if you don't allecate enough, youmight net be able to stae all elements 13. Inefficient Insentlun and delet: Adding oy Remeving __elernent§ hem the middie 6 tanay yequive shilting clement’ —_ , Which ean be me “| eonguming 2 —_finerFrefent ‘A. lack oF — Bullt- i methods: Unitke highey-\evel | data _shuclines _Ceg, Anaylis dmay dent cone | —atth bull io methoels” for covmmen _epenattons |_the adding cv _yemaving clement s 15 tem__anly Slr _Hemageneous Dalds Anay can stae aly —Clemenk of same type . t hel _i¢ _yenfable _lerfih aygument, explatn_tth ogvam — - 1 methad__qlth variable length ergaments Cvavangs) in __Jova__con_have | eu ov_muttple _— arqumeny . - - Vayjable feng th__angumenls ave mest useful when the _humbea of ciguments to be passed _— {o__Method. - : - a they ako reduce cede ag overtondecl_methads one nol _yequived. | QEo=-8 fr f - i Nagrann. po “public. “class Variable Length Example rt public ~ static weld mre Narang s hing sh) po pan _sysiem out. printtn (7 Neumiber oF aygunenls aes” 4 sholeng th) | Sybtem oul prindn CeThe_ argument Valued anes” 3; +—le_ (Shing sxsh) _, SystemGud. prinisln (8)5 — pute slate vod main (Shing age) pas “Navan gs CHapple eu! Arango", “pean; 4 NonavgsO.5 _ Now. ang.s Magic") 5 tt tp Nembea__oF angumenl’ a @ + 4 - ——_The_myament value cnes Apple ” —__| - Mangos st : year Number of ongunen8 ave so The _oxguynenls Values ne s Number” gp aygutnentt ove: 4 __the_ AGamene values eve + Mayle i ASSTGNMENT INO 04 ——) plata [fyglatn_inhenhonce and —ond_priymaphism_Teanies of face is used fo achieve |"maltple —_inhenitance__in jas | + Inhenibance + : ; - The capgctiy of class tod to denive 1 —piupenties ang chorddlenistics fiom __anethen_clage ~ Inhen!\ance__Yepvesents__jhe __1$-A_yelatanship ule 1 Known ak __parvent__ Child _velattenship. > Sygtox + ass “Subclass 1 -nome extends _Supencless-name 5 method _2 Tields z Example? _[Empoyee fam fig~ puqrarmner is subclass 2) Settny: Roat | —_Emplsyee i Supen.class \ nV ogyarnm ey Reyatlorship —hekween luo classes | bomuss int) ig___ Programmer __16-A Emo — [ Bass Lope = “That any “40.000; = paguarne, extends Emplayee | 7 ; 5 ~ | ink honus= {0000} — I =] [4 / parma ne Eeeenoneed _pubte_siahe void maa (hing gst) — of pf) st 8 | “plopamner p= new — Prgrammen 0; System. dh jinn InCopy aromas ey salony isi oy cae aul-mintdn ! (Bonus Efe (S24 bonus yh 3 — oO a at. —— SIP, —_Proguammer satay. “13440000 i a B [ Bonus oF Programmer _Is (600.6 4n__dbave_example Pregraromen —0¢C24$ the fielet of ——_—— Sun__class__as_well_ay _emplsyee “class. steakuves: a | A. cade _eusability= Subclasses ute metheds Lunas. —,ficm the —_Supfactags —————|-2-Method__ovemfeling- Subetagses can. inary “Sipaclags ———__|- metro 3 Super Keyword Access — Supenclas Ss irdhed and —____ | _Comshuctas | Ae Tupes._ suppl. —single, mulitlevel g blennehical a |__Whevitanee t BSA Relulionship-_ fs) ‘abhishes_ a paver child hieach —__| &- Acceas Combal=chly public! protected Penal a > e_aceelsible tn = a pings = ee |= The pyweess af Xemetenting, oF (a - -mulliple forms js know _ ay -poly me phism. aly rrexphisim Tek ya yenfena a Sat actten— In different ways Ni x 8 [= tn real: Hme example, In mall yor, behave _Itke cuglemer,- _ Jn but you behave _WWke__passengey _and_in _callege behave _tke_ Student at hae _ behave. Te —coughter, mye \ “= Types — a oe nehod _oventoading Ceampile- Time -polymaphigm) __ Mulhple —_metheds_auitth_the _sume fam e__tut : | different _pavumelea.s within _a_single class. (Teles Mathoperatern | f _ — int add Cinta) - { ou Rel mn 7 | int—add Cint_a.int_b) | $ - | a - I “Yetunn ath; + | Was 4 ~ - — pili class Main ___ — — f pabire—sioHle—vuld_main (siaingt}oxgs) { ! 7 mathoperaiion maths new Math Openakion0; / System-ou- print Cmath. add (5) 5 Sysiem.oul- print In_Cinath. adel (5116));______— 5 et - - Feta ee ee Se | =A subclass —_avanuides 0 method fH eens Te i H rice ana Sa i id { | @ovenide “gla scund.© = iT fate tpl. Cael") t phe So Matp . | = |e eae maan(shing La —— 7 LL ae enew DOs a. oF en ee tas woof : = 7 Pecan: = 7 ——.,-1_Methad ovenlsadmg Same method narne wtf dtffenent _paramelers > — | o Method rer s-Subeless edetinet nes ——___ | —__Supenclus s cl _ 3a 3 Dynamte_ el dlp etch lid to —_ Cat a} vane - — a ‘ i av : \ \\ ie | tk {soHem Relaionthip: Subclass —chject con he vefaencad | by -SupenctasS aye en “Inova, rouliple Inbenllnce Chere class inhenits “fom —roulMple pment —claseer) isn't suppanted _dixectly fer classes te —Quclel enim sue | tke ~ “diamand —m cblem.” ‘Thig_apmoch __ehethlei_c_clugs__to intent t_behavfoy _____. Inple__sunces _Githayt crediting conflicts. Finexface— “SchalshipHader [a — eis | Flags staaent—tnglerenti_Sehlatiphades, — = aia clnshipDelalls QQ : a riabce csengineeningStudent 3 ~ : : Ta getcotnseDetallsC —_ - I | | = engineering tucent - { I ‘yaa “prittin C*Delalls about schalershp); | 1 | a 1 t Ht i J _gelCan se belails Q ___ syslem-oud.pinidn (*hetails. ~abuuk_cst_cunse.9; Bet eres Geen —__| kan 7 Ist “| gubelass: = an this. extmple : schalqrshiptatdey, — i “The chadent__ Class implemen’ bolh f [- “and CSCrgineening Student el _ |--this ere aliae Guden! to _inhentt a | Ram both —_tnlentaaces cupphowd Ihe complledtions [ “of class: balect maltiple _- yphentLance-———— due: a) Explain ~Yelatlanshnp._ between — ~supenclassand___ / Subclass ith _erumple a | __ Supelass — : — _ —— iz ‘class__thell_is_inhaited class Ahet_inheafls _by_anothen_class_18 jhe suipenclass— ig 5 uperelass as { i -} Supenclass. ___— “gem. functionally ‘fxends ov modifies the a Sunctionalilyy oF Supenelass : proviel es_g Ov__propert}es- - | Suporelass members phen prypenitet 2 methoclg _[-aie_ inheniled > by __._ fre superclass : _f Toubolygg. 5 cluss Animal clas doy. event Antmadt jo ee Wold eat vold_pnkQ t Daya ee —_ |] class Dag extends Animal — ei] fo oo 1 e | Nola pavkt) = it Silom pin Charing.) = I _ - oe - ; os tt class Test Class fo en puoi “slaltc_valel_main (Shing mys) = |) (yg — : eT Dey d= nets Dag Oi Beak aij J) d- ett Oj; - a I} 53 - - __ lp, banking: oe a Ht Galing - - — 1 Ged Wha me gel) and Sel O method wn joe? ——_ Slate _adydintages of cpt) _and_get met heel. + Ser) methods . : ; = gels oy “updates the yalue of a _pivate vail - +S} = —Aypically yoiel (no kr value) - = = Jokes — a pmamyley oF _Nanlable’S type af |e voaifies “data with optimal validaHon. = Mluws —corballect _madificcwam of private delice =uarting volte} to _an object 4 ‘publie elas Maun : — publi _stalie Void_marn(Stilngf} angs) Go : —_ Student students New Student; —__—AludentsetNome Calico); eae neeeel ftom cut cpintn CS et tnme Scent gl iat 2 ; : — lp, ude! Name: Alice r i - oo | Advonloges of get 0 mend —— | seomholled acess to private Duta: es ea | 40__methods __ravtde A _ysdy 40_ACeRS_pyiverl e Rod ield'S _tuithowd _@xpasing tpemn caivectly 1 manntaining —encapsuiaten: flo Read mil -Agoig. © a | 1p thene “Is only a. -get0_rnethod endo seb) methad__%x_a “field {the Pred becomes -xeed-cmnly fier. _Ouicle__ the clogss 7 48: Plevibihity fea fade change = a —yol__an__ehange how” the data is accessed a Caletlated ingide the geF0 methecl usthoul arfecting othe “penis of cocle thet use this dada _ A_consistency _{n_Naming Conventtangs = — 9a methods Glow? _a_cons stent _hayring pattern That__meikes cade cosy fo _untenstant_ & wratalaln 5: Betten Debugging + : ——} debugging —ov_Jogging each _acceg¢_Jo #hal_data, which __1_wweful fe hacking haw data tg being twee» : ss i 1 *Aclwantuces fet method: ——,L.cmbolled _modifieaton of privele Data —SetO_methocl__allow _qui_tu modify private fells in |__a_combolled ae —piesewving encapautaton and ——-|__Ppevenltng divecl _eress- oe ——1oDaka validation: oe > SchO_methed can _inelude validate togioto ———|_theck the dala __befene 7 wing a gelO method 42 acess a flelel malleus fos | | PITTI ELI : fe aa a Hote nly set0_meldond_no. get Weed ‘Yhe_ field becomes —_tenlte- val. which can be tera ahen a field — should only ‘be Sel — hut nat_read i by estan Cocl. C- — As Neri bit ~ fyorre — changes _ Open dtu ata 6 glared 1_pucessee] Fn_setC)_methed_uutthouk —allfecting- other part —_ “OF code that get this dade -—— 5. (nsidency in. Name Conventicms+ “¢et)_metheds_—_ fallow _a__stanclayd — netting Conventim. whi h__helps—_manlath_reciclable 2 _comglstent code egjectaly —in_larg.e codebcde, Que4, Deiribe the ures_of cupett keywords with adpect | 4o_inheyitange es _—— And, The _Supey__eyguend in java _1s_usecl_In_ cantext of inheritance Yo _refenence members. Cfield, tmethad& _-ancl__amshuctas) of c._Suyenclass | JL enables“ supelass la __decess cy trmwoke Superclas methocl§ & amsbuctas+ = ______ 4. neces —Supenetass_Comshucta:- eee Super) 18 usec to ll fe _Supenclaiss’s onshuctoy-- a i =A Z class Animal a § . E ————Sysemeutguln C'fnimed_conshucley cate); u ay : [Jeluss pag externa Animal Lt ep we = : EE |: a ——Sgpem.a- pinion. Cpeg._conshuctan aie, | =a, ic “talled - Dog _comshuctay calle! 2. call cupenclass. method — _ Suporr. methodName cell a cuperclass mnebhad that os ee eae en _ [class Animal Ea vo - —._Naiel_seunt { te —ti said Anime! ab, fil Sound : plano painttin Ce Amel Suand); a Suna a { _f | Supey -Sound Oo py ea nL (Gag sana yt 3 ; Dog Sound —__ Shing _name_= "Dug, | Sete punttame 0 7m as {— guest infin (Super nome) i An. Eo ¢ Steyn. cul. “i niJn (name); — —j| ae a a I dp, Animal — 7 . - = Nog. = = —_ a a pirevenlicte —supeross rempenS ——-__Super__haps distinguish _Supencleti® members __ _______|_ hen hth eupewcleite and _fubrlefis have tne fame —_1etobiea_nernes ss _ | as _ Aniwiay ne a om hype = “Anire ltt ji atsplaylypet) ——— sient (ype 2 tee), he —S2 _ - —— = “hq ie a | re ee Ee z | Super display Ty peo | — — System: cal patie CTyp bye} | ab. Type: “Animal Types Dag — __ | = tite _diffnencet—baween terface — _and,—abshact — al a es _ | class» __ “Inlenface Absinth tags | econhack ai bluemint — “eA base class with shised — ! TUE — | fox classes. Pocus | chnvae! enistics allowing — *uhat! a _¢elass_ Cpl —tmaplementalter——_ hawld cw sil eee implementation - - = “coitatia anly sabshacl an _amtain_bath_dshadl ae _—__|__ methods -_____— and Tatty —rmplerenten— method S “canon have_stabie £ —+can gave —ynskan © vantabls— - final — vetont) fs. Ee SSuppatS mule - fer Ca class — an + suppan! 18 single “inhenttuice only class can — CON (my ernend_enlplep jnlerfaced). hall Class mus4_do, — Faishacl tid ane [sh ece gpa [oda asl Claas | Specifies what a “clea ——__- must_do and how ~—. bu ot _how to-do It...

You might also like