0% ont trouvé ce document utile (0 vote)
16 vues11 pages

JP LN-3

Object-Oriented Programming through Java empowers developers to organize code into reusable, modular components, enhancing efficiency and scalability while promoting concepts like encapsulation, inheritance, and polymorphism for building robust and adaptable software solutions.

Transféré par

buppalaiah13
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
16 vues11 pages

JP LN-3

Object-Oriented Programming through Java empowers developers to organize code into reusable, modular components, enhancing efficiency and scalability while promoting concepts like encapsulation, inheritance, and polymorphism for building robust and adaptable software solutions.

Transféré par

buppalaiah13
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF ou lisez en ligne sur Scribd
> Arvays!~ “5 THI nae, We have! dis co ssod haw le dadave vewables dk a pavkealay dalatjge, which can stove * single Volue: y te seve * the gittaktons wWheve We weigh wis! in a Variable + a spevol ind dob eve ave grap oy similar Boe th volust 3 oH caw be achieved by ehrudave Kuno at avvayt+ vw An array WS a collection de Simile J a data Shudtinrs) Lheva we Slove Biri low de elemanls in on Onvey” index bated , firs elemout ob The ac dele alemudy od i YE laments. We con love only Had eek > Arey in qova is is loved ob OC2eve) lex ascray ye andet “ Ota sus 6 LT] seve leg is + Advaukager k_anoy! > code lopimiidltion 4 DE makes tee code opi ped, bla cam wakave. sort tee dal entily. ee cam get any dats located ak ony > Random aceats % index position » + Disedvauloga oy avray ¢ > gira Liwh ¢ We com Slore me away. DE cloesw’ grad’ ike size ok only fined sna ch element iy santima. Te sdve. Tay pablem, cotledtion dromework used in gave. cso pat oh avrays! Thera = ane + Single dimensional axvay mulk dimensinal avray . Single dimensional awry ¢ ak ie an array With only Gt can be visualized as a Sige peslavalion + pataljpe Vorriable (1 (or) palalgpe vaviablel I, t no ot a chums = new dabatgpe (sre; one dimension (9 inden» tion 4 Tralvelia dom venable LI = my Iveta or) dataljpe § chant, elem ie system - ouk. pritly (rnartes cia) 4 j q gabakt 62 st 30 40 a a7 vaviable = new dolalgpe (sire) Ext ink omarke(y > new in (51) a (Cay tab wenn [= Las, 70,80} ink Marts C15 marks = new tak (SL Example : class Single Darray puble slakte void main (Stang args Ly) i ink marke fT = new tak Leds Ij Declaveadon marks Lo} = 60 I Terhabi aehion marks CIT = S82 ink marks tis mares (22 = AO tor) whee Baty = 822 f co, se, 30,80.98.29} wmoriet (49 = T82 mayen tS = 40, 11 prinkivg, volu in 8tey AB Cine (E02 Te mares. length 5 iat) + Mall) dimensional amy ¢ Te ig an array with wo Of more dimensions Bt indatios. Th can be Visualized of a wabin ds raat ond colens. Libs take a -hu~ dimensional away, Sn this ca" dala Clovad Wn sno and column based “index Calto Kan og, Mabix eet Ue S2 63 oS 66H 6F 39 £3 oF 64 9G Fe OF 65 99 BE EE macrks C204) = 985 maves 27 05] > #25 I piinbing 2-D ayray 5 be marie lenght 4) $ fa cink de fe wBectia. engin: 4449 L system. oud rm (Moree fT +" "00 pal 05, 4 console. inpat and output Con) contole class 3 oy Ty IRS, He Teavn about gove vio Consele. clas. This. convenienk methods fa neodivg inpat and slancayd ghveams ¢ Reybood aud decplay) i conde class comet vader class provides biting output te command -LineCeontde vars, nile bnet pea Jove. io’ peceadé > tre Contcle clacs provides -follaaina vnelhodt, these ave. contele!s oukpok opant-o) = thiles a -fAmalTad Shing i gleam. = oodhine () — Randy a sult line & Feule doom conte! input shreom+ aod Pastoovd 9 = Readt patword tom conide. inp Steaam Ulith echotag ditabled - Exar import java -Lon 5 fpociage class Contedeioem? t public slakie. vod mainL sug avgsl) Cortde C= ysl « coms! ce pant} C* Ewley your memes rwodlineQ) W conde inp ")3 Heonsele autput Shang wame = C* co pint Ci enka you Company name > py Ching cnowe = cone in 200 coprinb} (" Congralli “1S vw" name) + coprirlt CY you one The employee oy Company * 1S", Crome); g if oukpst- — gavae Contelein Dewo: Jeve gore ConsoleioDemo Ewey yoy veme } Machu Ewler Yast Company, Nowe } TKRCET tengeall Mediu Gan vata Employee of Compony % TRRCET % Scomney clats$ 45 The Scanney class comes tundey gaya -vt ibe used fo geting Wput doom Ubeye > Syslem i a class m te jeves hat Wivee predefined Vaviables : in, ouk and ext in -tefeys to clawdayd ‘mpuk Stveawr Chey board) cut veleys to Slaudavd oukpuk Stream (Maver) ere, vefers te 3 Te Stanney class Uses objet Tae scanner Clats have —follawing Methods enextlinet) — dk nebieas the inpuk ac a Shing. ae neteloatty - TE gulderat Tha input at a Pleek. erexkLowgt) De vehi he impule at a Lowy, sherk ghod O —Te sabewnt Exawplet- import deve. ORL 5 class ScamnerDemo { public stale void main hing Scammey sc Whew Scauner ( System -in) 5 avgit3) { System cuts prinkly CY Ewldy your Mamet Ghang name = Sc- next Lined; Sysldon souks pant Cawley yr age "J; iW age = See MextTank 05 ° System veuts printly (" Hai " +name) 5 system souk -pwidla (° yruy age ts “ page)s, i cubpub t+ ‘Jovac ScannevDeworleve qevo ScowatyDemto Eafe youv wowe Modhe ealiv your oft 10 . lang package clandavd evroy outpuk Skream (maavilv) , i get ypu dam Keyboord (Slérdowd inpuk Steam)+ erent OC) - Te vel ee imput oS 9M iwlagev . te impub at o Short . a wekbasblety — Tr mallivat The tnpuk at a deuble- | 1 package « And Ths class Arvarable % classes and obgeclt i- cane, cue oven pagename) (avquoge + 4 o0P> qavo paste bailey blockt classed aud obyedi ane ak of prolelgps all cee as common papers pev, method + con suey] x classes t- A alana, H/o bluep™ Variables and yneliods eomaeaon fo je a gee ob obgeti thak cr) A class conlain: dala mem > A class inqava con block , class and indieface + Syulix te cectave a class class!) eclass name > i Uvaviates dedovedton methods declavation 5 >a class can be detlored by Ihe nome oh the claw That Yu coauk fe deknes “s the’ cate badly contains Yorn differeul lovelon ond Methods dedavalin. x obgeti s- pn obseck is 4 LoPtysave: pundle voriablet awd guolalzd Methods Mokyel- {5 ‘on wines of & claus ie by vaiably and methedy in sig, obgede, We can able 0ceet Wal claus Split dedave an_obgerl- elay-namelds claw—vame objet mame = New (or) in guert, Synlor is eve jp a nome oe clay, becawe user-defined — dake Got Kipe objec name 5 cow aM The keyword “wuw’ is used fe allocalé wowery al vunkime » + Zaslance Vavhable : nh Vaviable the method, is Knaon +s inslaw gek memory at compile time «Dk gi obsed- is Created « hab ic thy, ik ig neon that ‘u cvraled ‘ntidle the class bul oukside) co Vovioble. « Gaslavee memory at vaudine Whe at mulznte Vovoble Example & objede and_clase glade sts Ne? dade news ng yet ouch print (5155426 gystam cout panty (3+ awe) jk age =30; i ae S02 ented arable ching, fovancn © "CSE" eydamn .ouk. phvtla Cur oat te Fageds systein -ouks pinta CT gray branch Bt a branch); 3 ofp: jovoe Shadaok «eve Jove dhudeut yay tee 2 52! yard aunt Medi yor age Ht Cse yo bowl © Y Sn This enamplé, la. have, Craalesl Shitent Clase’ That have he ove Creaking the obsect jon dole wontevt id oud name variable doer class Shadewk i ink A 51 pants sere (ale iatliau whe Bing name ="Mad he! public stoke vod main (SMG avgst)) ainethed: sgek & sidell dk te Shdenk Claas by Mew Kayesord and piudeng tha obs Vole. i A yevo. method ik a colledan ob alalament{ that av cel lagetiney to perbdm an optvabion. | | > None of The melheds can be decdavad oubsicle the clats. > Al) melfiods have a name that sharks with a noe case Chavaclay+ >In ava, Methods ave used te, * Make tue Code. xouable . + Simplify the code. + Topcon progrannming: > Tava Suporlt lero ype ot melhiods , Those « Dnslance methods :- These 0% used te [Link] (maw pulale aud also acess ove. the iuslance vavia bles class vane blet- Meads :- “These ave used Ip access unless + Class. cla Vvaveble bul cannot access Me inshiace vadables objec 4d thol purpose: and unbil they use an Syntax fd Method peclavalion Cmodrdvers) ~olawn Wipe i eletementi lis f methid bey weliod name (pavamedie- Lit) I iq the above synlox, x modifiert Coplional) - deftones WE SCOPE Cpublee ,prokeclea , defen or privele). a talisen Kype - Ub can be either void Lip no valve is vebiomed) 07] ipa value ts qalimed: ae mMebhod-name - The maltied Name mutl be © valid Tava letter), tdendekev. (methad name glavlf Ktith lower cate x Deva melev i “i 5 ethed by Ushing the values in pavan (hoses olla Ing mothind wome- T Yous can poss one of were values te a * Metfod ely + tyes otethed Indy efines whal fhe wwothels coe Aith ta sfatomenli Example 2- Tha -follasiag encrnple 10 demon steals avd has ' coll *t- hno to cline & note ingpovk — Jove. ston 5 pullic clase MaxNumber if public state void main (Sug ovgtt Contcle c= System conte 0) copantt Ciewley perth number 0") iN- a= abiger-porseTond CO godine) Copwnb U“Ewley Second number wl} ik b= Aulager: parteTal CC rsoaklin 2003 ink mone = Mox Runction' (orb) yskia cout. pintln CMaxivaum Number eS ene, } public slalte ink mocpunchon Cink A, teh nr) £ tak wan teu >) Mane MW, ofp: avec Mox vue Tava alee java Moxnumbey wan = "15 colar fevsk Number + oe yin Ma 4 7 olin Gecord rem bev ¢ J Marinnunt Namie 18 = sé. Example A method li import gava-fox, Pubic clase Gade f public static void main (Shing S Convole C-printd CY enter int marks 2 Dilegev + paws Qvacle mares)’ 4 public shite void qrode t th Chmaves >= 40) Cystomn. cut pautly CY Cade ay); else it Cbmanee 27 +0) Syslow souks pankla C* evede Bl); else iH Ctmares >= 50) System. oul print C* bvade cl void vetinm lgpe. vqct3) ce cystam - Contde OF guy waves fw bw o te Sut (¢ spo kaewds; loo ww"); Cink (antes) ele Gystem - ouks printla U Gyade BD"); j d op Sever Grade -“yeve Jove Gvede Evlev Yv Mayes tae o te loo ar Grade be Mole Gf a welhod is cleaved uaing ake Keyoord , Gee oheverise, Whe ho wed to cweata an obgut te occast ib. Lb, pelt canthgek oud Then occers miethedt by using Thak obje Evomple? The fellas ing ehample Sh . abil: ‘salts hs ge Saat abled alg: loalty import java. io-%3 class Cole f public stake vold main (Shug ovgsl3) f Cole aby = meer Calecrs sobgat corrtion Be clays Cole Conse <= System contlecrs copankt C" Buli deve number"), int x= Dalager + parsed Levrveod Lime! copwinkt (" Eala Secoud number"); ink y= Talagey - pose Tuk evwead Line, obj - Sum OY) 5 obj» SubC%Y); t void sum (tuk a, ink b) ‘System -[Link] CUsum b+ Catb))} B 3 Void Sub Citak a tak b) t w A gyldna cook pandle C gub ws J i opis javoe Cale - eNO et Cab} ue tale coley fist number 20 evlev tecond name’ s fom te wb IS

Vous aimerez peut-être aussi