Download as pdf
Download as pdf
You are on page 1of 76
Vivelle OS w AIntvoduction +0 Osp ard Java Overview of Oops #* Objeck oviented Psograms is a Ptegsamming Vanguage allows Programmes to develop Softwarse- * Three major families of language © Mochina language 8 Assembly language © High level language © Mechine language ie Menaunge A Machine language os low level \on guage Consist of th Numesie code Which Con be executed by the Compuker. Whe codes axe. Strings of os ard ts. © Assembly languoge Assembly language os Assembles isa Compiled 5 lows level computer language - Ta Assembler Mnemonics Oge the nstsuction See fos thar Proce sgor. . Exarple ADD» SLB »Mov / ; @ @High level language \ High level ‘into \ Nanguage ove classifies *Proceduse ovtented Poogsam ming ; language * Obect Ostented Progsammni ry . language . * Proceduve. Oviented Programming language C> Cowor , FORTAN, HIML * Qiicst Oriented Programming language Main okjece oriented Programming ‘is tbrying to simulate Seal K Fe things ines Yous Procedural lang Gage : Y @® * O0p wos Introduced te overComa Plows tn the proce dusal App mach to Poogsamming Such as ~ > Reusobility => Maintoinabilicy - Fundamental %dea Main fundamental idea behind Object Osiented language to Combine into a Single Unit both data and functions that OPperake on that doba Such AS a Unib is Called as Object: Benefits of Oop eo Te cor easily Upgsade fsom Small System to lasge System - “¢ Easy to Pastition Work fox Same Program * Message Passing kechni qu Cormmuni cation easier . maxes “ Software. Complexity Can be easy managed - © * Maintenance Cost is less ° Simple to implemant. Objeck oriented Programming Paradigms © Object oriented Programming isa Programming poradign based on the Concept OF Objeck ewhich Contain =D Data => Gde = Dara Para wn the form of Fields Known as Oktsibutes and Properties = Code Code in the form of Procedure aoa as methods. he Software. aa Using Oop Paradigm is + Easier to odept loo the. Changing veoyuivement ¢ Easter to Maintoin © Create modular of Funckionalrey © Promote Qseabexr cesign ¢ Be moze wtobust © Pesfosm desived cook efeiciently - © Feabuses Feokuses ) program axe divided inco simple elements Called Objects: 2) Foeus is on Properties and functions Cather than Procedure - 3 Data is hidden f¥en external functions ; h) Functions Operabe On the Properties (axeribute) of an objeck - 2 Cops allows decom position oF & Problem j into GQ umber of entities clled Obiecks and then builds dota and Runckion © The dato of an objeck Can be Accessed only by) tre function asSocirabed With tha’ object - * However, functions oF one objeck Con access the functions | of Obhay Object A Ob} Objects ee ~Y | \ Ss w oY Features of object Oriented P¥ogramming Q SES _F obbeck Oviented Psogsamming a (Baste Concepts OF Obfeck oxiented Progsammi ng ame o Classes ® Objects ® Data abstvackion ® Peta encapsulation ® Thheritane © Polymorphism ® Dynamic binding . © Message Passing © classes > closses : ase User deftned dotsa. bype . => Which Nelds the entive, Sek ok data of a ‘object: 7 Tr isa bluepsine ora bemplate OF A Sek OF Ofecks Lohich Shave. Some. Common Psopesties and behaviour >A class Gan be defined as an Cneiby wn which, daba and funckion Owe Put “bogether a © Sypeax Class Clessname_ Pri vake+ Naviable declarati on; Funckion daclavation; 3 £3 Clase Student 4 ches nomefials ‘ne Nos, Purdt cr Notd gerdatac); 3 ®@ Objeces &® ¢& \ Sa ave the basic Unie oF Oops), \ —> They ave the instan@ Of. class Which have daca rrambes_ and mamber Function Le pevform task: —> Te process of Creaking of the class is Called Class instanblabion: objecks Syntax Classname_ Objete -nams ; (os) Class class_name Objects - Hames | | &3 Class Studenk S)5 @® Data Abstraction —> Bara Abstwacktem epsesenting onby essential feabuses oF bhe application by hiding aN Ghe Amplementotion dax oils - Example. Riding a bike — > Krew bho essential mekhod te vide a bike. Rs. ® Data Encapsulation ® —> Fundamental Gncept - —> Dara Encapsulation means binding of daka Variables and method btogerher treo -a. Single entiby Called class. —> The dato inside thee claws is accessil. by be matched (fp) in ble Some Class class (reared © nberivance ros " * . y +> Tinkeritan@ 1S the Ptoperkty in re Ushich pre chess Con acayive and Use he Prdperties OF another class. +> The existing Class is Known ag lace class ov Super class- — > The. new class is Knewh 3 derived class Or Sue class - —> he dasived Class Shaves Som |! OL Lhe Propesties of the base class- 9 an aa \ q a Code from Oo & bese Class Can be veused by a daxived Class - > Therefore £3 Shape is the base Class from Which civcle » line 5 vectangle aze dvived - © Polymorphisre sf oc; Polymosphism is the abil ry og an. epesaker and Sunctien to bake more than ohe forms) ae > “re differens bYyPes OF Pelymorphism ave- : © Opesator Overloading * Function Overloading @ Dynamic binding > Binding ig the Psocess OF Connectihg one Psogzorm te Another - —P Dynamic binding is the Process OF Vinking the Proceduse Call to a Specific 8 5 cauente oF Code or Function ak vuntime ov oluving the o: xecukion OF the Program —> Oop cat oF © Communicabed with each other —> Objects Comm Wrilek® toith each other by senting and recerving Wfeormakion- Adventesge © Coda veusability ® Data Security * Extensibility of Coda ¢ Less maintenance Cosbs. * Rediices sofiware ae oF Weck thak © Creation and gmpletuntakton Code is easy: yo Appl cation > Mobile computing > Real time System => Business logic application: > Web based applicakion | — Game ptogsamming- | => Object oriented chotabese => crav/cam system | oer Tova Burdords * Java is an Object - oviented Pregrotoming language doveloped bby James Gtosling and Clleagues ar Sun Microsystems in the eavly \aais *. Te Supports Variovs foany, res lig Classes, Objects » abstraction b e 2 Qh Capsalasi, inheritence: are polymorphism . mon RS [Choractevisties of Joua x © Simple © Ovjecr-@¥iented . Compi\ D © mopiled and Ih bexpre bed ® platform In deptndent ® Robuse oe © Distei buted @ Maleithread Portable © High performance Secu @ Dyno © © Simple > Ts is easy bo write and more yeadable- _ > Te is easy to leavn and its Syntax is simple- ® Object- Oriented > Tava Programming ts Objeck- Oviented Progtamming languoge-_ = All dara and Program code Teside within th Class Qnd Objeck- > Tona provides most of the object oterked features Such as Objects; Class: inhevitarte Polyrmnos phism eke - Serna reece “4 . co > Ton compiler pytece yt Yinto O opecial code called —> Tava inberprete? a aN, byte code Treo O machine coda Chi ey , i’ => This mdehine code * diwen’ exacuzed bo Obtain the Oub Re Gource Coda filename Jon) The Process be Gropile @ Jove. Program: Tava, Vi 3 ~~ Opevaring ja Virtual Machine} bubecodas System (GevaSocerpreey) eke Colaesn 5 @® Plactorm hdependaint ee ee >Prgrams in java Gn be ercacubed on a Varieby placforms > Tk can sun on Any } imachine with any Processor and any operaking Isysbem - ® Robust. ~> Tova is secus ed ond veliobl is Venphicitly managed. Je because memosy © > Tove, Uses Inbuile memory management System called Garbage Collection. © Distributed —S Distributed is useful tn hebwosking environment © >t I on ditedrenr Compurers Can Communi cake with each other: , | —> Tis Gn be achieved by AvP Wo differenk Objects RMT CQmbce Method “Invocakion)- ® Multithseaded —> Java provides iwtegrared Support For mulrithveadad Ptogramring. > Te Gn handk muliple tasks Simulcancously © Postab! a Te Gn execute tn any environment ond any platforms. —? Tawa Programs can be byangferred Over world wide cocb £a applets oO —_ . oo \ ® High Pestormance \ er use ttecorle the 3 Jang hes bigh pestermonce. > The use of mouleithveading alse helps to improve. the Performance of java. Secure, > Toro. provides a Secure meang of Creating Theermer applications. > Town provides fo access wot applications . > supports dyn Qumie new Class, ibrasies Method 5 : > > eds and ol eck] myo TJaue, Source le Sha. oF moye Class eS nitions. * * Jove, Source file must be Saved With a, eXkeng; ton of™ Save” @ ty x To create java Source file > we Need Ony one OF the fllowing © Notepad ~-ext editor * Netbeans — A ova Toe” that is Open- Source. and Free - * Eclipse -— A Java xe developed by the eclipse. Open-Source. Community . Java Source File Structure Documentakion Section ~] Package Statement Tempore Stakernantk Thterface Stakement Class Delinition Main Method Class L Doin makhod definition 3 i) Documentation Setion Recumentabion Seetion . . SS * Documentation Seckion Pray, . OF Weemakion about the program like the marie Po gxam, the author Name and other iS * Is is a Sek Of Comments. . * Comments ase benaficiol Br She Ptogrammar because thoy help, Ghar Urderstand the code * Te is Met Crecuted by Compiler ond interpreter - TExan, ple A Author : Sam/ single ina Comm ene /* Program fo adld tivo hamb eis */ rules Line | Comment. | i) Package. Stakemens | aE Bhabemeny i * +e the Jaya PrOg tam, ‘nvolves the Package. Stokement ‘ike Should -veturn bre Fist Stakement of Che Program, * Ib is SPional . Kose ove} | : frag Sgnvox Facnage Packagnann 5 Exempla Fackage ani mals Class C Aw ral Pub ke Void va abe C); (Ln post Stake ment popes oa DS TRS | Sbotbement anclude le and muakchod yooyuired Fox Soave Pregzarornng * > The ‘Impose Statement mokes extesnal Clesses anolable bo the “Cusrent Java Source Ppses vam Ab the bime of. Cormpilakion « Kauyeoord innpess = Supcox * To Import a Single Package» Woe Specs AS import Package name; ° TS import all Package $, we Speciey 5 port Peerage: Memes x - Examples —— Pes ‘import Javasio se W) Tver Face Srobemenc oor > Trter face is Wke a closs but ‘ib Sneludes Sroup oF marod. datinizions- ™ Wes an optional Section Keres ond ‘InverFace. Syncox : “Interface. “Winter cename Exarnple. ‘interface Studank Publre Void, Geedatsac) ; Public wid, Aisplaydaral yy sj and mebheds Qv N) Class detinttions A Jova Program May Contain One oF move Class definitions > his class Contains the doba oking bhe dokka m anipul ey oord class Sygnko closs classname L UM scovernents 3 Example Alass ciscle dane); Ni) Moin Merhed Class > Every Sova Program rayuirve Khe main method as the stavting Peink oF the Program. @ are of a essential P ~~ This is an Sova Prog wann > TT Jawa p he. ing Only one Class defines Math methe . Cxample Elass Sample, Public Sbobie Vesy main(String ergst3) f 7 Go or Chak Makes © Accessiple + all Classes Statice Method belen 3 to entive ol Void — the moin method does hot Yeburn Om Volun . String Vine OGL —_ ass 89sC4 — Used fay Smmand ey) FT De << eo. LYPES x So Pes Speci¢ 4 we ae a y the diffesent sizes on nak Car be Stored Sn the Vorioble - * These are too bypes oF data types in Java © Primitive dota types (CP rinasy) @ Non-psimicive doka types Cuses defined) of Poimitiwe Pam Pai okie Noo Syperrridive 7s rao ze ~~ 5 N Vc Arvay Poe Ne \ Reolean abject ebjee- exc th i Une | ie € | “oo \ Choroeees Treegra} Chowvede? oe 2 AN Coo Flecaa e804 went Zloaking -Poirue obi ‘ iN “> Lp\NF> chas bytes Shore Ink tong - Float double Chay Bytes Sherk tnd lerg fiene doeble © Printtive. dato type Cprimorry) —TNve dake bype \primory) ; The Psimiive dare types include 09 Integers ®» Chosacters D> Boclean d Floating Point numbers. * Teva defines eight Primitive. types ec dove s bute * Short © the © lon * chax * Floor © double * boclean * These. Can be pe Fous groups. a) integers Thtegess Qsoup Includes d byte * * Short eine + long in ie) which ove forwwhele -Vvalued Signed Numbers - i) Byte Data Type = Smallest integer type => Ib is an s-bit Signed integer = Ts Volue-sarge lies berween —j2g to 127 Example byte a=lo; ii) Short Dato Type >The short dara bype isa We-bik signed ‘integer => Tks Vale —vange lies between (-2X16) to Cae!) Example short ab; it) ae Dosa, Type. The int dota type is a 32-bit Signed Snbeger- => Tks value vange lies berwean (-221) to (231-2 =) Declaved as Inb Lxorple ‘ink O35 ee ‘y) Long Dake Type The Long dozatyr® is re eta ©2683) to (263-") Example long Qsb3 Fonge \ie2 buses, b) characters —This Qtoup includes \ + chow Ushich tepresents Symbds in a Choracker See Whe OLetters © Numbers = The chav dota type iso sing W-bit Unicade chosockes = tes Valus—tange Vies beewen, G26) bo Cate-l) > he chor doko kupe 18 used to Store Chorackers - Exar ple - chav x= A; cs oO Glee Le & a ive le cose “ ey c) Boolean This group includes » boolean ushich Is o special bype Los vepresenting grur/ false Volues a) Floaking- Pane numbers This gsouP includes * Float double Which represent humbers with frac ional precisi on- 1) Floor Dave Tyre => The Plear doko bype ia Single -Precision S2~bit Floating Poine Number - = Repsesent seal number Exsinple. | Floak f= 2au-sF f ") Double Oata ype & —> Te double data type is a double —pzecision 6y— bit Fleaking point number Lome y 9 olouble. d= ma3 eS “ Array is a Gllection of similox type “oF memory \ocakion Noune-\ Types OF Assay — \ypes oF aszay in Java @ One. — Dimensiohah Pera ® Multidimensional Arsay. © Ore = Dimensional Array | . * An assay is-a group oF \ive'— byped Vasiables thak ase wefeveed to bya Common name . a he we x An array doclavation has tiwo = CompomnantS the bype « bhe nome utwre *sype declases bhe Clement Eye of ; the anv’ : nome denotes the —_—~_ ' | | arsoy OMe” Syneox Daxakype. Nort -name C35 cot) Darobypel J Vatname + & Tne of 1 5 (oA) Tne i as Tnstantiation of an Array in Java New operator ig used to AMecake memory in a Arvay. Syntax avsay—- Vas = SST Naw shee typelsizgs> c nit sin at Example i SJ class Tesrasray i sy 4 Public seanie void main(Seving 079502) £ ine acy = ine[635 // declerokion and QOJ =20, instanki okion aLoJ=i05 3 Dprincing, Array Fox Cine Fees fea sl tho i++ iS the “a D Mergen Propeyey of avrys. edtem Out *Pringd, (acid); lo 20 To bo 5o Avia initialization -After Cseation assay Clemonks Can be initialized explicitly . a @ Syntax LJ ortaynome = § Example tne CJ Num = {iyasao¥08} Declaration, Tnsrantiation ard rivialankion of Java Are Example meses class “estas uy! q purlic Staktc Void main(Sesing ongst) £ je C2 (33939 95 GosCint t= O 5140 Nengeh3 i++) Syseer + ouk- printlh Cais Ourpu . ¢ @ Maleidimenstonal_ AY oy is an . ast % Mulzidi mensional hen 1 acces an ° oor Tay, khar uses move +! Ossay elements - x Tease axe also Known as lagged Breau # Muleidimensional O94 jg Creabed by appending ona Se OF sryuore bracers (63) per dimension th vows and Column based index [known as matrit for} - Syntax Datatype asvaynamelI£I; Cor) Doxacyper 3 OxFaynamel J; Astoxy mstantiake Memory allocation - Syntax * ‘ ame 1 yee Var—1n, CICI = nes ae a Ceol- size) ; Example. 3 J Darnorscrake O tio diwanstonal onsay For mabrix- class addition Truleipireavion { Public stakic Void main (Sering argsts) ire Citi = {Con}, fara, farang} 5 —_ HS q ey qe BCI CI= {howdy Layard, §31393453 Tl [en289 another mnoesie bo S he BeoUle qe C307 ere ‘ink (ed C235 [size for Cine 120% i23 yet fox Gre 4205 3233 54. coats =% E For Cine K=05K=99 Ket) > jectiICiI+4 C769 | 4 # bOICII; gystern «out paint CC CiICII + ae iB Syst eci3cs cen « ove pret OD 5 3 Ounpae 6 6 6b Din te ig@° 18 & a s \osiatles 3g “ [ER wate ig a identifier Which hel, ot the Volue and thak Can bechanged Aisi ng ‘Khe execution of the Program: 2 A vaviable ig assigned with o claro ype « ° Nasioble ig a name of mamory loeakion - \ Syntax Chra_ type Vartoble names Value 5 Example ‘nt ab; Chay m= ‘a; Valid? Vasiable Names Kala ; botal mares SAM : ° Soma. ules for Variable. . First Vhe Vaslable” Character should Not have: digits No Special character’ ig allowed except Undesscore. daclarakio rm ave =o ——— i ed 3) No blank space is allow ad. ox! h) Te Should nok be % Kayioe’ 5) Ik should be manringtls). on Ar: Operators oe (oe Jove. Poovides a wich Sek of K Opersakors to manipulake Vasiables - * Symbols Used th the expsession. — \ * We can divide all the! Javor Operakers into the Following Qvoups () Arithmetic Operatorg ©) Thevemene and Decsemant Operators @) Me dulus Operators (vy) Relational Operators W) Boolean Operxaterss w) Assignment Operators (vil) Bitwise Operator - (viii) Temary Operator @) Avithmette Operators - > Arithmetic Operators ase. used to Manipulate Mathematical exXptessiong. ee ———B Example +r eS Gi)Inevement and ete +t Operator Resule + Addition Calss unary Plus) | ~ Subesaction (alee onus) ~ Mauleiplication_ / Division x Modulus += Addition assignment -—= Subtraction @sSignment x= Multi plication assignment Division Assignment Modulus assignmenk Decrement Operabors ond —— are Jawa’s jincsement and decsemenb operators - > The theverrent Operator inczeases “XS operand by one >The decrement Opezsator dacveases 46S Operand byore - Operator Raul os Theremont —- Decsement Example J remorstrace pre increment and pre decsement class TncDec t Public Stakie void. main (Swing sgt) | System + out prircln “a=” +a); | System + ouk- printlh (“b=” +6); © System - ouk println (Hc =” 4¢)5 ou w e u NN Oi) Modulus Operator we dale Operakor, °% FE UH. Che semoindar of a division Operakion - Te can be applied to Floaking- point types ag well as integer types Example Poemors trabe the % operalor \ class Medulus q Public static voi 4 a main (String args) ink X= hos double Y=u2-255 System. out: printle (4x mod 24x 9; 7 2 System -ouk printle(% y mod =" Ys, 1D 3 Ouuspute x med to =2 Y med loz 2-25 ey Gy) Relational Operatoy rotor => Telarionship that one operand, has £0 the other: > Specially > ed hos, determine eoyualivy “And ovdaring . —? The outcome of thase Operations is a beclean Valua . Example S= LS 9)

The Boolean legical operabors Shown here Operake only on beolean operand, : > Bl of the binasy logical ' Operators Combine. +tivoboclean Values to form @ esuleank boolean Volus . ace Operarey Resule Logical AND Logial OR Logias Xar (exclusive. oR) Showt-civeutt OR be Shor-craftt AnD Logical Unery NOT AND axsignmens OR assignment XOR assignment Equal to Now eanol to wy (Vi) Assignment Operators Se ee ee —> ssi gnmant Opesators are Used to Assign Valuoy toa Variable. > The lee cide Operand of tha Assignment Opevatoy js oMocsiable: ASSignmenk Operakos tg a Vos SD The sight sre OPperanol of Lhe Opesabor Rosule + Rddicion OF +0 humbes — Subteraczion of tio numbers x Multiplication of too Numbers. Wa Division cf tive husmbers xy: Modulus a class Assignments Public static void main (String arestt) ieee String name 5 > % Hum =10; Tame = “Gopal” | System. Out printls (“num fs ANH grea. / + rum); System - out *printl( “nome. ig Wi gned 4 ~tneume) ; 3 Ourp ee Mam is assigned : 10 home is assigned : Gopal (vis) Bitwise Operators > Tova deftres several bitwise Operators thar Con be applied bo the Integer Lyseg ® long eine i © shost 1 e char e bybe | | | Diese opevators ack upon the individual bis of theiy Operands. Biewise, Bitwise OR Bikustse XoR Rivwotge Complement Bitus Se Shige lee -- & YR > Bicwise Fb sight Oia’) Ternary Operakor —— rv —e Ternary OPerakor in ya jg Used a, one bneay weplacamenk fey if - then-else Statement > Tr is the only Conditional Cpesaror hich tals Cheese, operands. Syntax Sendition 2 expression] : expressiona Example claw Teropre) q Punlic Static veid main Ceuring avgst3) L String result = Cnursber| Number” 1 “ Nlogavive Nene System. out» painels Cvesuble) 5 Ine Number = Tb» w So)? “Positiy, 4 3 Quepur Positive Number] | ed Contre! Statements K. _ Le A progtamming language Uses Contsol Statements to control Eh Flow of Exrcution of pregram beaed on caxtoin Conditions - % Tova Sauppests Ehyee Gbegorieg og Gsntvo| Statements : D) Selection Statements FH) Tkesarion Stakemants M) Jump. stakemanks SS Contto\ Stakements Samp sisterents} (Chile leg) Pelee] S/S do while loop a enneennnee >[ Nested if else) Dp Selection Statements — > Based oh bre Condition Slack bho Stakement — > Selection seatement ts also Called as Gnditional statement —_—et Stakement > Coregories of Sdlaction Statement axe @ iF Statement © Switch Statement Simple 12 Seakerrank 1S Ehe Most Simpl, rok 3 Scokemant - >t is used to decide Whether a Btakerrant os block of Stakemants Ce &fecured oF Nok- \E Ceonditior) q Wstolemenks to Cxocute i M condition % 'Yue. 4 & Exorple class \or Oy Public Static void mein (Serirg owgse J) 4 int a= lo» b=205 Te Case) 4 System - ous - princh (“ats flow gore 70.) 5 3 4 4 Gi) if-else Stakemant Thre Tova if-else Statemt Abe bests the Condition: “STe executes the if bloc iF Condition ig tue else iF else block is executed ‘tc is Falke the Syntax ECcondici on) Wexacukes Chis bloc pF Teondition is 4 else brite Texarsures hig bloas Te if Condatio, ig False Cap le Class lay Public Stati & Vota, mem (String Sas) is tht as lo, b=20; if Casey o. System. Ou primtlny (a ag 3 CNge L 3 lowaese?, a); Stem out printin( big 7 we? BY 5 “4 ‘) s¢-else-if laddexs Stakrement >The if Statements ave executed From Aha top down —> Tova if-else-¥ laddes ig Used to dacide among yuleiple. options 7 —> The cenditions Controlling the eis byue) the Stakerrenk associated with kheb W is oxecuked Ord (rn. Test of Ere \odder is bypassed - SIF hone of bho Conditions 3s Lrur, then the Final elee Statemank will be executed - Syntax 1 Coon dition) Statemant else jig Coondition ) else Tf Condition) “LD VF (wee = = 1) L doy = “Sunday”; else if (week == 2) if dawg =“ Mondow?s ==> else ie (oe L day = “Tuesdox”s else iF eee’ == » 4 doy y» i Care) | £ System + out: princlnCa); else 4 3 System -ouk- pvinelnCe) 5 3 else { iF Cb >c) L 3 System -oute- pyineln Ce) ebe f System -ouk-piindnce) 5 eee Eee Outpuk 30 2o lo © Switch Scokernent —> Th guwitch Stakemenk is Java’s mmultiway branch Seatemsenk —> Te provides ar easy coay to Aisparch execution to ciererenk pares oF Youscoda based On the value of on expression. Styrtax, & Susiech Cexupsession) Care Vou Vt breax, Cose Value 2? break « 2 Case Valu Nz We Weak = 5; Stsing dau ; Switch Cree) q | Casels lay = “sunday?, brea 5 Cose 2: days “Monday”, breaks, Case 3: day = “Tussday”, break ; Corey: doy = “Wednsrdeys”: breaks i Gose 5: dey = “ Trussdoy” 5 | break 5 . | Coreb: day = “Friday”; bseaks, caret: day = “Saturday”. been >, ° detoule days“ invalid day”; bseak; 3 System - out: prinkln doy); 4 . {ne 7 sn j : oe [Sy omen Stews Sy a park OF a Prog», Ne —> To repeat ” 24, until the cnclizion is Sovishred | ( —> Tresarion Stokermant is alag “Called as Looping Statement - > Garegories of itexacion Statement’ are @ while loop ® do-while loop © for loop O ohile \oop > Pp ohile loop is a Enter Flow Stover © cee allows Coda. ig *epeatedly based on a Qiven Condition - — The Whi be Cxe cubed Boolea, \e loop an be che OF aaa Vepeaking ie -_. an <> Tras —_—_ TT — os Synbo coi le Condition) it If body oF loop 4 Example class whiledemo 4 Public steric Void main (Seeing argsc3) £ ine count = 1,1=O5 while Ceounk <=9) L qainds Sysvem out: psinels (Fhe Value. Yo of 1= ); Count +4 5 ¥ 4 yi Ouspur “he Value Of i=! The value of i=2 The value of f=3 The Value of 1=4 “The value of 15 1s © dloccile loop —P do-while loop checks for amdition ACter Ctecuting the Stakemanks and Therefore \ eis Gua ay Exit Gnerolled Loop- Set Cortiolled Loop do Example Closs dowkiledemo qt Pablic stakte void roin(Sering ovgst 3) L ine Counteloi= do | ae Systern out “psintly Ct ghe Value of i=”) 5 Count ++ 4 whi le Ceounk <= 5) Ouepur re Value of =) The Value of 1=2 The Vole of [=3 The value of f= The Value of 1=5 | ‘

You might also like