0% found this document useful (0 votes)
40 views

Java Imp Assignment 2

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

Uploaded by

suraj Patil
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)
40 views

Java Imp Assignment 2

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

Uploaded by

suraj Patil
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/ 12
(Gate J Desived Gyntadicad conshucls jo Java’ hat ts coanstsuchy 2 Explain its typed. Constructex is specie method sticlass having || (Same name as the “class name. =There {is fo need to cot! the constructor explicttys it gets autornaticaliy Invoked Coal leo cohenever an objet Cinstance) of the class is cxeateod. — =A constructy cohich cloes met have an pasameters ts known as clebault const *. — IF programmer lo net define constuch* tn class »theo compiler creates defawH constsucky tox the class - Parameterized Constsucts A construck: with parameter is knows o+ ametrized constructor = Fox parameterized construct we Can pass “the axguments oher objects tox the clase ‘is é. cxecctool . ¢ [rs 1 [bae S || Wak o prggram which Ghow the use! ion ee nstruelot overloadigg . Ans: public class Student x s oY — fot ils String names Studentorg - j System out. poioHa Citic la default z constructy ")s 7 ce student Goi testing i fa vei S85 * ae ame = 95 - public. static void main¢Stying fl) ened here: Student s= dew Students ; System out-prnilC\n Default Constuchr vwaluess\o "5 stem.out. printlo ("Gtudent Tals "4 Sid + “Ln Stuolent Name y “t6.neume)s System, out. printlo(’ chrdet Pasametostzed Construcky youluer t\o ")5 Stuolest Gtudlersd = new Student (ley David") System. out. printle Studes Dds studest.id +" \n Se Name 3 = = S.name)s oa Si Wiha ts array? Write prgram fos amvey sPobjedt Array $s collection ot elements st cimilay date apes wel Pened b4 the same Narjable name, | Poegyem te lf Chess Arey? [= public Ctatic veld malo Citing La anas) Tet LD myfey muyfrray Snew Ini tsd's MuUfrray Lod= 103 muArraAl i= ao} moprrag 12] = aos mpyArrey DQ) = 405 muArray [41> 504 fos Gok [Hos }c muhrray length §)44) System out puotle (NE lemest ot todex Ppp eng Arey C10)5 $ $ Output MPlewenhiotvinder a le TlElement at index 1% 20 Elemen| at jndea 2% 380 Element of index 5% 46 Eleset at {index 4% 5° i awe ar Wihabstspictstog & Explaio’ aiterent stying Aas: Sat ith. cn oxcemple- —— See Tis caqaunce oh chatoled Be 2A Kun ac = % ctslny eh s chaxctes: =m Methods of String t Fe _ consicdes G6trings: “oKeenet | — ion stilag sty = Kunal" 3 = wae (pare sting st = > Phoenix Infetexh 5 —~= : @chax charAt Clot fnctex) * =a Rekuenis the chavactox of Gpesitied Node Example» (a Sj stem.o ut. pr otle (techarMG@)3; a oudput: 0 la @ fot lenghO = he ‘Returs lenath eb sting . Examples System.cut. priotlo (ctw. lepsth)s Output 2s Ping | Substing lint bessicDnelex) + Returns substuing trom spesitied index up & end ot +he string, Example 5 System out. printly (sh.cubstingé Ds Toudpat wnal 9 eee Bealolrelex , fot endinden):— om Spesitied Index ap a | aa aren Beslene sins blait 4 Sting ae = R truce iF the sting stests with given ~- predix. ; Example » = ad. prloth Gets. Ghasts With Co Ku"))5 Rekisns true if the shia» ends with giver aulfin. Exam ples» | System. out. psinHo(ste-endsini tC abe"))5 it ince? Clot ch) WRelarns index «+ Hirst ocouvsence of Spee Fed jen! « jag. care Bubfer shee ger Sia pe Kunal" fot C)_ fom : é Reduxns | th “std ple s ne ea aril NengtbO)s Oo eS jot capacityd) 4 - i 5 Retusns tote all ed capad Example » Systemout. protlo(Csb.c ODS Oo ut 3 2) 4 Cit leo) e the | lenat the butter within a« StingBubfer object. Exar le» < SU siisten. out. sintile (0) G) char chasAd int Yoclex ) F Rekwns the “choveustor «b Gpecitiad Index. ~Protlo fsb, cheers AF es i tts Cite st Ge aa etpud n Fare ert ie # © roid edchasAt int Pos» char ich) o * |. — ses a ha aha ch at positon pos. EMA) (a ; F Gh edt hawt,’ s)3 Outpud » Kusal Shipyauksking( ta bipltlmens intr enlindanye Bay: eat “Retusns eubstring Drom: bepinTndex ‘index to endinckx ot the sting « Excumple 5) Systom out. priotie (sbs, substing( '.3)5 output oun Sting rep leice Cobar olds Chas neo) 9 Rejusns sting by ‘weplacing old char by new chas, [Example » Sting sty = kunal"§ System.out. proiln(ste-seplaceG’,*m'))5 Outpul Kunam, rn) aT oC) Fompni(Shig SHIT — 1) chosAt & al : f Schaw chashtCint inclex eae cs aT 1 Refarns the cantor vot specified trex | Example » E Bese: out, Prioile eke ebay ae o. is tee a prpyram te seardh a number 19 an Blas res public state void malod siaiant a jean Tat um: a aisaia es jot teHod = 83, | besleen found= Rilses _¥ox Cnt ns num)§ = W Cn==tefind) > i Pound = true§ breaks SAPD pr et > ate Gourd) Systemioud. prinils Che finde "ys Band.5 t System.ouk. pad loCeHind a “Ys nol Pound "Js Sis Pound. rite_a prggraro fo demonstmte the Pollowing. 9) te convert lowes case shing +t. upper hese, > Te post Bava.u], Scannes 5 Public class Lowes To Uppesd) Private “static Scanner xy Public static void maisC Sting LI axgs )4 sting lowsts a SC= New Scanner( Sustem.in)s Spstemout. priniC’\n Please Enter Lewescase Sting = "')5 lowGtr = sc. nextLineds String lowSte? = lowsts toUpperCased 5 System. out. pantlaC'\n the Oppextase Sthing=" + lowStx2)s put &-

You might also like