100% found this document useful (1 vote)
40 views

Java 1 - 6 Practicals

Java practicals Msbte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
100% found this document useful (1 vote)
40 views

Java 1 - 6 Practicals

Java practicals Msbte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
VIN T TTT CTO OOOO EEE EE Java Programming (22412) VII. Resources required Sr. ‘Name of Suggested Broad Quantity. Remark No. | __ Resouree Specification ‘ 1 | Hardware: Computer (13-15 preferable), Computer RAM tminimim 2 GB and ‘ System, ‘onwards As per For all 2 | Operating Windows / Linux batch size | Experiments system 3_] Software idk. 8.0 or above. TX. Resources used S.No| Name of r () Remarks Saas Broad Specification Qy (ifany) J coe Computer G3-15) | | System = RHRAR Broad | ROMA Saiztleace Bs ! specifications } 2_| Software 1 Windows 10 3 [Any other resource used Jak U8 oxabove Practical Related Ques Note: Below given are few sample questions for reference. Teacher must design _ more such questions so as to ensure the achievement of identified CO. 4. Write installation directory path of your directory? ~ 2. Write value of path environment variable? 3, List folders created after tallation. | 4. Main method is declared as static. Justify. 5. Program is named with class containing main method. Justify. | (Space for answer) Java Programming (22412) MENON EA AS cccnrrine emcee ae g pein t..of.a.J Ae Pa.g7ean7. 4.00. at. dohegtatic.ckecouseus.is called. bythe. lava.Mintwal..tochine.CoMM)..te, start. the.execution. ethed..is..c...canvention.the. ith. the way. Tava.lecotes..dhe.entay.paint.. on OE.a.. program 2. 2.Kecube.o. Jawan Pregrom., tbe Jarer Caturt.) to0.ks...er.the...roai.n...methed..c. Java Programming (22412) 1. Ife if statement is simple decision-making statement, It is used to decide whether a certain statement or block of statements will be executed or not, i.e. if a certain condition is true then the block will be executed otherwise not. Syntax: 1 if{condition) { i // Statement to execute if the condition is true; t 2, {f-else: The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition false, else block.will be executed. Syntax: + if(condition) { 1/ Statement to execute if the condition is true; } : else j J/ Statement to execute if the condition is false; } 3, nested-if: A nested if is an if statement that is the target of another if or else. ‘Nested if statements means an if statement inside an if statement if(condition!) { // execute when condition is true. if(condition2) : sie } // execute when condition? is true. 4, if-else-if ladder: A user can decide among multiple options. The if statements are executed from top down. When one of condition is true, the statement associated ‘with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed. III. Resources required (Additional) k Nil IX. Resourees used (Additional) Sr. Ni of m eas || emarks Se] Nameot | proad Specitcation | Quantity | “rang | 1 | Comp vice WompeterCiz-is Ereeremelianmasiaa| * | a | Softwore | JOKI-So8abo 1 ‘Maharashira State Board of Technical Education 24V0 Progr wMMing 2419) abe RraM Code: - 3 stad Teacher must assign a separate program statement to group of Mea og lage Ne nw Program to check multiple conditions using if statement, PobIte Rat Condition { Stotfe yet ; i aes Reve ere Class orgs LI) f e boolean isStudent = false; Cased =18)4 + Stem. oot: printin C’ Pexson 1s Adel t)'s VEC isStudent) £ System: out puintinC Pewson is a stoden +”); , Close f System. oot: printlnC’ Person is neta student”): elsef 7 System. ov: printin C' pexsen ig nod Adolt”) 5 5 RUSERQEREQERCEUERNEC KY eft XI. Result (Output of Code): XII. Practical Related Questions Note: Below given are few sample questions for reference. Teacher must design more such questions so as to ensure the achievement of identified CO. 1. List operators used in if conditional statement. 2. In if-else construct which part will be executed if condition is true 3) State the condition when the else part will be executed with example. E6886 4 Faharashira State Board of Technical Education Jaya Programming (22412) 4. Which of the following operator is used in if ) fn, Assignment operator (=) b, eomparison operator ( (Space for answer) \ ase . e 7 Lee ove, 2Ayper.oheperatene,.rsed.in Uf. SAwlemen) 1) Relational.operators: 1D. Logical operators ==). nEqvel.£8 C&B)..n..hogise. AND CLz) =) = Grventen.thon.eq tal tein ie. Beit: om Tn ifcelse. congdmuct,.the..tatement.in. if Condifion Te dxve.then. the. fixot.powt.of.ifnelse..means ‘GP! stodement..will..be.erecvted..: beth In. iPr else. statemend,.0f.the...cond Stadement..1S.falee,then.enly.the..else.paxt will... whe.eXecuted. sarc 3 F _-Hexes..an..exampl ee number €.2. pple. StaSic.aeld.ain Cotming ange.) PCnumbes.<2).. ‘Maharashtra State Board of Technical Education Java Programming (22412) XI, Exercise: 1. Write output of code in the given space. Sr Ae Program Code Output 1, | public class NestedIfixample { publie statie void main(String args{]){ int num=70; if{ mms 100 ){ System.out printin( “number is less than 100"); it{num> 50){ System, out printin( “number is greater thar: $0"); } } \ number is \essthan \oo| number igreatertran Bp 50] 2, _| class 1fStatement { public static void main(String[] args) { int number = 10; if (number > 0) { ‘System.out println("Number is positive. } ‘System.out printin("This statement is always exeented.") i} Nombe 16 positive: his statement 1S always execvted - 2. Write a program to make the use of logical operators. 3. Write a program to check no is even or odd. (Space for Answer) Jaya Programming (22412) cease value? : // Statements break; // break is optional case valueN © // Statements. ‘break; // break is optional default: // Statements | } 2. Conditional if (ternary operator): Syntax: result = testStatement ? valuel : value: ' VIII. Resources required (Additional) Nil ; ' r IX. Resources used (Additional) Sr. | Name of = Remarks all Rcarce Broad Specification Quantity ‘if'any) 1 |Compoted | Computes Ga-is) System | RAM 2 tobe R 2 e weg ere [IDK 1B ovabove X. Program Code: Teacher must assign a separate program statement to group of 3~ 4 students. hs , ‘Write any program using switch-case statement, Jaya Programming (22412) XL Result (Output of Code) XI, Practical Retated Questi Note: Below given are few sample questions for reference. Teacher must design ‘more such questions so as o ensure the achievement of idemified CO. What will happen if break is not written for a case in switch case? When d ase is executed? List datatypes allowed in switch expression? Write a program to make use of ternary operator (Space for Answer) Dut fimwe.den't wsite..bseak..charemens.of4s.m..0. Cose.in.dwitch..caser This..0ill lead...cte.erecuten... ofa Scase?...and..will. candinus...the..execudlen. bo the.ov.bsequen.t...case,...Statemenct..vnAil...b%eak Stotemens.is.maitten...on.the..0nd..0fctb.e.Sttdedo on Lase.. of. gwitch.case...when..allthe existing. 6a6€ Sonn become... Palee.. s Inteqex, Dovble. conn Deere, CALS. ot a OB. OMowed..in..oiteh. expressions.» Maharashira State Board of Technical Education 8 oT prespessesse: 4aééd4444 4 eet Java Programming (22412) Java trograming (22412) XML Exercises 1. Write Brror/outpt of ode inthe given spnee sr Error/Ou Se Pighin Cols Error/Output | | Public ctaxs SwitchCasct xamplel { Public static void main(String arg) | int num=2; SWitch(num+2) | { | ‘ease | | System out printin("Case1: Valve is: "nun; iord Ay cave 2 Default valveis: System.out printin("Case2: Value is: "+num); case 3; | System.out. PrintIn("Case3: Value is: “+num); detault System out printin Default: Value is “num } Public class Program { uy Public static void ‘main(String{) args) { int value = 100; Program jovaBiert0 7; Switch (value) { .: case 100: duplicate case label | System.out. printin(true); 2. break; Case loo; case 100: a ‘System.out printin(true); a aim desor } 2. Write any program to check switch-case statement using character datatype (Space for Answer) 5 ‘Makara Ste Boar of Tonal Eaeaion HAH \ 4 \iniitonnl) NL \ Hai Xo epram Coder Te A Nendtents. Develop a program t XI Result (Output of Code): aharashira State Board of Technical Education V | jhyoned Specttiewti ® | Computer Comp [Ramen here | | | yor) Borabere_ nase assign a separace program searemen (2B 1 print command line argument using sroup of 3- 2 PERARSEGQaaaanae 2HOOO BEE EE B ® L_j_§ O° —— fff Peper ey ee — ‘ample questions for reference. Teacher must design such questions so as to ensure the achievement of identified CO. 1, When for loop will be terminated? 2 ‘we write a for loop without initialization? If'yes, give example. jable by 2 in each iteration, suted infinitely? ¢-a for loop to in 4, When for loop will b (Space for answer) Duthe. Fox. lonp..will he tenminated..in.2.cendisionsss Wurfsthe.leop..condition.evolvates..folse;dhan woth. e. Loop. will.g.et...texmingt¢d..an.d.cthe.cantsall... culwon.e..to.the.next..Statement.de.maintain...lew.o foqmam.l.Code... nae are - er WD) Whenwe vse break! stalement.within.the. loop..Ab.exit. dhe.lomp....eqondless. of the. \eap... ..€andi sis, oa : . sei DNeS.me..can.Wwaite.c..fox.leop..witheut.inidial: Atem.in joven. this.is.usedul.whenthelnittalization heloop.vaxiable hos. beenolxeady.dane. chepaintinG Texation At) yn tex.dhe...leo.p. A aS as. Maharashira State Board of Technical Education 5 Java Programming (22412) 2] Se eHmlAAS ctheve ment: By Two. ae Static. void. main. CStaing. ax gel 1) : fos Cintls.op ilo. ite 2) aSsstemouts puintinC Index ti). aerate 3 2oThe. fox. loop mil, ecuted..intnitely..undex. Such. prssible. conditions... a Eee D..begices Exxon. in. Pyrgxam... W.Tn.cuement:./Dectement..., ) XIII Exereise: 1. Write any program using if condition with for lodp. 2 Write — any program to display pyramids of starspattems using increment/decrement ‘ ) (Space for Answer) r Maharashtra State Board of Technical Education f TEETELTEELETTS SITS 33 a spe sage y Java Programming (22412) VIII. Resources required (Additional) IX. Nit Resources used (Additional) Name of | Broad Specification | Quantity Resource _(fany) Remarks Computes | Computex G3-15) Syetem | RAM=2 4246 | Anyothey wees) SP Kl Bove bye Program Code: Teacher must assign a separate program statement (o group of 3~ 4 students, Develop a program to use logical operators in do-while loop. Result (Output of Code): ira Slate Board of Technical Education 30 ae SSS SS SSSI IIIS SS ep bee s Note: Below given are fé ‘more such questions 1, State difference between while and do-whil 2. In do-while loop termi 3, How many times do condition is checked at _ Je loop will by ample questions for reference. Teacher must design evement of identified CO. loop ___(beginning/end) ied if condition is false? (Space for answer) br While. Do-Wwhile }).Condition.ts.checked... gok.then, Stadement. ig.execures..... W.while..lesp.is.Enimy, Contmalled.loap. Aotement.is.executed.... Otleast.oncesdhenatier Condition..1o.checke... Doznbile...s.exit Send oNe...LO6 Poon =.In..donwhile..leop.tesminetien..condttion.is. e.D Once, while.loop..will.be.cxecuted. atleast... if the. .condition.is..false ‘Maharashtra State Board of Technical Education Jaya Programming (22412) XIII. Exercise: 1, Write Error/output of code in the given space. Ba Program Cude Error/Output class DoWhileBasics. ry ‘ini v { 2 public static void main(String args[]) a { ita 2 » 2 1 { d 3 System. out printin(a); 4 aeatl;// ora; ib while(a<=10); } class Test { ae public static void main(String[] args) | T 2 while(true) { et System.out.print(1); A 2. dof 4 ‘System.out.print(2); ? } while (false); t d Siate Board of Technical Education. LELPPPPP PPP PPP PP IIIT III IID ISH HSH SS

You might also like