Address
:
[go:
up one dir
,
main page
]
Include Form
Remove Scripts
Session Cookies
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
9 views
18 pages
Final ProgCodes
java questions and answers
Uploaded by
ayesha153mohd
AI-enhanced title
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
Download
Save
Save Final.ProgCodes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
9 views
18 pages
Final ProgCodes
java questions and answers
Uploaded by
ayesha153mohd
AI-enhanced title
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
Carousel Previous
Carousel Next
Download
Save
Save Final.ProgCodes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 18
Search
Fullscreen
tea net uno tat mds asttfinogescee tana pins ean of eV. Telos ene ate ise, Hn ide anomie sn fy a these Haste ers eg hen Fenians: + ou mstonner yur ce apap + urcodemst tees eiaetaspssle + Alumter at tobe sto corsa. ser eat eg, 10 23, 408) 7 2] seater san = ry Searer(stenin); 3) dita; jfariate the else | int mms ety wriate 5 a] a 7 | sysenavprrta rer a unter (@ to auit)")5 | msc); ting te iru fon erty i inside aril an 4 ae] may u res x]: Ba] i naan * n= s| 3 wl y | ase, System pitta fever nbs ic “my 1 [ineite a JAVA metho dey tht eas users ful name an stores it as one sting. The mathe shel then perform te fling + coments our amet a uppereas eters and pts it out othe screen + converts you nat al fowerase tas and prints ou tothe screen, + insta lngth ofthe name and pints it out to the seven Hi: You nay assume the Scanner cassis doady imported for you. Forevamele: Test pat Resa eer) A ne Re ete ll Te lag of yr “Answer: (penalty opie: 0, 10,20, 3,40) usie static void Seantty() ( 11 wre your coe Far the meth here Scatnar scan ~ ne Scaner( System) String nane = scen.nextLin(); Systen.out.prinen("Plzase enter your fullnae: *); systenout printn( "Your nae in upercase Is: “sranetotppercese()}: systonout printnYour nae In lovercase 1s: "onan tolowerase()}: nt Length = nae. length); ‘ystenout printin("The length of your nane is: “slangth); ¥Hit: You may assure the Seanner cassis areadymporedfer you Make sures cere an use a constant fr soragthe vue 20. Forecample: mat Answer: (erat regine:0,1, 2, 30,40) _Jpblie stati veld passuordchecker() Fine Strine poesvord ~ "CORICT"; Seamer scan = new Seamer( Syste} systen out gelatin "Please enter passiard String utePasmieré-scon.ext()s if (4serDasvordeqale("ORECT)) ‘ Systan.o riat("You have geised access to the syste"); Systen.cetprintla("our pasuord is Sncoreet!");ire mathed findFrstint{] vector nt value) tna tums the inx of te st occurence of valuein vactarar the 1 atherise. eguiemants * You must comment your code appropriately + Your code mst be as efficent as possible + AllnumberReras need tobe sets constant Forexamy Test Fes Sytem egitim C18, 28054038, 30), 2 re a pinion C8308, | + syste. arrest 08,209,508, 3, 62)3 ‘Answer: (penalty regime: 0,10, 20,30, 40) /Returns the index to the Finst occurrence of value in vector 1 Feturns -1 if there is no such ocurrence int 2-05 nt occurrence = © 5 boolean exit - Flee j ubSle(lodt Mt Avector Length) (value — vector[i) F occurrence = 15 exit tev 5 else i1(fLoccurrence 2 88 i == vector.length-1}{ Foceumence = lj eturm occurrence;‘tes method daysToSeconds that reads rom user the nun of day in). The method shoud then comer the numberof dys to seconds end isla the esl oth usr, Make ur user inputs vay postive, Jar consis of A400 eaconds, Requirements: + Yous comment your code appropritly + Your code must bea ficient s possible + Alnumber tras reed tobe set as constant Note: You can assume that Scanner lass is ead inorted fr you, Forexample: eat opt osu erent) Ete name syria); © Sterne ula tat Answer: (pent regime: 0,10, 20,30, 40%) public static void daysTeSecands() ( i Write your coe foc the nethad here Systen.et.println( "Enter ruber of days: “Ys Scamer scan = nee Searer (Syste. in); nt mun = scannevtIe()s (oun) Ssystenovtprintlnoun + "days emsists of * + sec +" second!" } ese { systen.out.printin( "Invalid input"); }ite method (occurences tht is the numberof ocuences of th infeger specie ste frst parameterin the ary of integers that is specified asthe second parameter, Forexample: Tet et) mes = 2845; i we Syste at. rntinie enrs careers ts i "aera. gates) ng) ames = (453405 tm, Syseua rine crs “ocorecs bers tes i “eras. trieate) nk) = AAA, iat car cect) raps. striae) Answer pera ee: 0,10, 20,30, 40%) s[public static int occurences(int value, int[] vector) { {start Jf sie loop vhile(lerit 88 devector length) sf(value = vector[i] ){ Foccurnence = 1s return occurrences 1 |iferd est ces 1 ti a 23 8,51 cs 2 1 5,3, 61 tere Sto 41,4, 411 Gay 1 “Systenoct print ‘ncareect int Y for (int Set;deniie iHfor low © system sriet1 9s | Fe Git Fi Fife | astenott ont 95 oo | Systenct pintin( 5 + oe (lot Eesboas—AN¢ 140° toe 1 stent print 1 "5 foe tine SoLidtea Sytner” Ye 2 Systanoat-platin(-+eres mata id age Sart tar tops nce cepaanae acre tz ogee schon maT, segue: + Yumstcomenyar app + Yarsesomattesrotson sone Note: Mote ae te parameter tars proves postive number Fereanole: rawr rat eg, 3403) SpE sac vets eacageasts(t FSSE ce fo aid ost eas cay ‘steed. pitlncrect ep); eum sts dinwelty fe (eS 8c sora joa ca 0 Sater eit) : Ii grant tes ne 2 ee syst. sltine 5 fe littse trae a) soy systevad. ain" > patent. pit" 5 soe sae ioe ease for (it estes = bm AIL Visas se fe Gat = 85
ww) ase a systen.ot.grintn("Pleae enter a valid year of Bsth); n| }ite JAVA method ina that reas nthe users est name and lastname and stores s oe String, The method sha then perform the folowing + Pint outers othe screen st characte of test ame ang win the fest cera ofthe ast ran). «tract user family name and print tthe screen. Hint You may assume the Scanner cassis areal imported or you Forexample: Test inp | Resut ‘niin | at ze ree ere yur eae ‘Answer: (penalty regime: 0,10, 20,30, 40%) s]oublic static void initials() { I site your code far the athod hare Scanner scan ~ new Scemer(Systen.in); String fullname; Systen.out.println(*Please enter your fulloa fullnane = scan.nextLine(); 10| char Firstinitiel ui | char lastinitial - oanes[nanes length - 1]-char(0); 2 13 | Sjstenout.printla("Your initials are: "+ firstinitial+ '." slastinitial ); 14] Syston.out.println("Your fanily nane is: *snanes[naneslength -1}); 5 16)/)]Witea meted insert that ales 2 parameters: 1. ainteer aay sorted in ascending der 2 ineger wae ‘Themathd shuld then eta he inex if he vas ound in he ara. ot, return the index were the vabie shoul be insertd in the aay. For ‘ample, forthe parameter aay (23457 and va 6, your method shoud rtum index 42s 8 wou be inserted after the valu 5 and befor the value 7in the ary i, atthe thine Note ay such uestos shouldbe soed with theleast runtime. Hower to mae things xsi, edo not onside his Moreover, youd teed ose the vate inthe ray jst return the inex where th value would elnsred Fer example Test Rest an) OHS = 58915 fi it ner = febartoonte, $j staat git; inf)ames -snameialy [7 int er «fuses, 2); site rites bs : fit be Seeberteioete, staan ruininn; od 1 stm Scere, 2) teat istinnn ‘Answer: (penalty regime 01,2, 30, 40%) Tp[public static int Finnsereider(int[] numbers, int value] { [/netiod 2] int a8 ube nrumbars. Length) (oubers[npvalua( //3F return 95 Hearn [ss 4 5 6 } 8 9 | return runbers. Lengthy Hete «+ Yourst commen your cade sppropdtely «Your code mus be as efcent as possible + A umber Heras need to be st as constant Fer example: Test feu 2 our cote For the method rf sjstenot.rintla("Tnvali putSas SS] er oe Gale Soa eae esha: ation seat — cepa, hae sete ran sess ie spa bey cei a ase (eat ie 0,1, 20 3,408) pie static seit) attr] res, Sng a) Jett bone faa - Sle vee (res egy e f 4 (nd = false one eplsignreaecmesné)) 4 08-20 nse] = ah Syste. itn + "as delete"); ) 4 (om 4 inst) = neste +15 ? nde ve i css Legth = 2) } 1 aed =tn2) { raves length 1 = lls systno rit pe 9" soca She (bie aes angi raeng { Sister. ita); ates »? cue ‘ ‘stodpinti|rne +" as wc fae); fete re HERES RE SRG ROR RY SEER GEER ES een eweWe a mathos cal caleulateciele tat ead the rads of a cee ana pints ts area (A= WR? and its cicumfaence (2 mR) Dsoa both resu vith 3 decina paces, Hin: Yournay assume the Scanner clessisaeady imported fr you. Foreample: Test Input Rest Coumacirar)|1s [ree ae oe as of me draw: Ine erence te arden 5 he piso te cue Ta ‘Answer: (penalty regime: , 10, 20, 30, 40°) Ts public static void caleuateCirele() { 2 1 Create a Scanner object to resd input 3 Scannar scanner = nay Scannar(Systex in) 4 5 J Prope the usar to enter the radius of the cincle 6 sjstenut.println("Please enter the radius of the circle 1 ube radius = scamer.nextDouble(); 3 9 J} Cleulate the anea and circunferece ® ube circumference = 2 * Wath.PL * radius; a ube ares = lsth.PL © radius © radius; 2 B J rin the results vith 3 decimal places u Sjstenut.printf("he circaference of the cinle is: 8.3\n", circaference); B systenout.printf("The area of the circle is: 4.3fn", area); 6 a 11 Close the Scanner object scanner. close)‘camer scan = ree searmer(Systen.{n); Systenut print "Enter size: rt size - scan.nertit(s (size > 0) { for (inti ats Lestze ; te){ //for for (ant $45 fe Ay He systenout.print(™")s + systen.ot.prbnea(">" + for (ln A ostze; bots 1-)f /Hforite metodHongestShing hl lesa prone an ayo sings andes the best sting nthe ra. Hin: Reena ta txLengn eu he eng ofthe sing tat Tat esat Siri] rs «(Pig oe’ nae gst sig is ne gra. secs“ gH); Stig] es « Pre) get rig ea ‘esr: “pegs; ag rai ea | ue rigs cage steal iesttnis: "zesreers Ane: (era aime, 10,20, 30,40) [pple state Seng Lngsttring String] sera 2] serig lest = amafe 3s) for(et 1a; aay. for Lop 4 ‘if(longest.Jength() < array[i].length()){ //if statenent 5 longest = arcay[i]; 6) 3 7] > | ceturn longest; 9 fivient
You might also like
COMPUTER SCIENCE
PDF
No ratings yet
COMPUTER SCIENCE
109 pages
Stewart School,: Cuttack
PDF
No ratings yet
Stewart School,: Cuttack
14 pages
JavaAssignment (1,2,3,4,5,6,7,9)
PDF
No ratings yet
JavaAssignment (1,2,3,4,5,6,7,9)
84 pages
Complete Manual
PDF
No ratings yet
Complete Manual
45 pages
100 Common Java Programs
PDF
No ratings yet
100 Common Java Programs
97 pages
Kod Chapter6
PDF
No ratings yet
Kod Chapter6
16 pages
Java Record 2024 Batch
PDF
No ratings yet
Java Record 2024 Batch
48 pages
My Java Record
PDF
No ratings yet
My Java Record
31 pages
Arrays - Revised.pptx
PDF
No ratings yet
Arrays - Revised.pptx
31 pages
External Program Outputs
PDF
No ratings yet
External Program Outputs
30 pages
Isc Class Xii Computer Science Project Java Programs PDF Free
PDF
No ratings yet
Isc Class Xii Computer Science Project Java Programs PDF Free
77 pages
Java Practical File BCS-452
PDF
No ratings yet
Java Practical File BCS-452
20 pages
little flower preboard
PDF
No ratings yet
little flower preboard
18 pages
MCQ SumOfDivisor 2ndHighestPalindrome
PDF
No ratings yet
MCQ SumOfDivisor 2ndHighestPalindrome
32 pages
AD 1 assignment
PDF
No ratings yet
AD 1 assignment
32 pages
OOP_Exp02
PDF
No ratings yet
OOP_Exp02
13 pages
Oop2 6.27.15
PDF
No ratings yet
Oop2 6.27.15
16 pages
Java Practical Assignment
PDF
No ratings yet
Java Practical Assignment
45 pages
HandsOn Questions
PDF
No ratings yet
HandsOn Questions
36 pages
CS PROJECT
PDF
No ratings yet
CS PROJECT
24 pages
Coding Interview Questions in Java for Freshers _ PrepInsta
PDF
No ratings yet
Coding Interview Questions in Java for Freshers _ PrepInsta
20 pages
A Man Pandey Computer
PDF
No ratings yet
A Man Pandey Computer
77 pages
Solutions
PDF
No ratings yet
Solutions
14 pages
Computer_preboards
PDF
No ratings yet
Computer_preboards
4 pages
Mod 2
PDF
No ratings yet
Mod 2
14 pages
651124127c6b1_1695622162_coding-interview1695622162
PDF
No ratings yet
651124127c6b1_1695622162_coding-interview1695622162
25 pages
Java Basics Batch30
PDF
No ratings yet
Java Basics Batch30
16 pages
Java Assignment: Name:Vaishnavi Rajesh Nagarkar PRN:10303320181124510060
PDF
No ratings yet
Java Assignment: Name:Vaishnavi Rajesh Nagarkar PRN:10303320181124510060
19 pages
Comp
PDF
No ratings yet
Comp
173 pages
Coochbehar Government Engineering College: Submitted by
PDF
No ratings yet
Coochbehar Government Engineering College: Submitted by
10 pages
Java Programs 2semester
PDF
No ratings yet
Java Programs 2semester
26 pages
Java Practical File (1)
PDF
No ratings yet
Java Practical File (1)
32 pages
GIU_2478_61_14171_2023-12-02T08_18_05
PDF
No ratings yet
GIU_2478_61_14171_2023-12-02T08_18_05
8 pages
GIU_2478_61_14334_2023-12-14T12_53_54
PDF
No ratings yet
GIU_2478_61_14334_2023-12-14T12_53_54
10 pages
CSE110 Methods & Final Review Lab (No Submission)
PDF
No ratings yet
CSE110 Methods & Final Review Lab (No Submission)
13 pages
Class 10 Computer Specimen
PDF
No ratings yet
Class 10 Computer Specimen
15 pages
Https App.oswaalbooks.com Download Sample-qp Subsolution 763Self Assessment Paper-5 (1)
PDF
No ratings yet
Https App.oswaalbooks.com Download Sample-qp Subsolution 763Self Assessment Paper-5 (1)
4 pages
Doc1
PDF
No ratings yet
Doc1
6 pages
Revision 2 Important Programs
PDF
No ratings yet
Revision 2 Important Programs
15 pages
TUTORIAL - 4 App
PDF
No ratings yet
TUTORIAL - 4 App
13 pages
Specimen 2025
PDF
No ratings yet
Specimen 2025
12 pages
Assignment 08- Method_3
PDF
No ratings yet
Assignment 08- Method_3
12 pages
Java Ideas: Last Posts
PDF
No ratings yet
Java Ideas: Last Posts
19 pages
Assignment Java
PDF
No ratings yet
Assignment Java
11 pages
Https App.oswaalbooks.com Download Sample-qp Subsolution 714Self Assessment Paper-3 (1)
PDF
No ratings yet
Https App.oswaalbooks.com Download Sample-qp Subsolution 714Self Assessment Paper-3 (1)
4 pages
Arrays - Class 1
PDF
No ratings yet
Arrays - Class 1
13 pages
Computer Project
PDF
No ratings yet
Computer Project
55 pages
2023 Exam Review
PDF
No ratings yet
2023 Exam Review
6 pages
CP2 Assignment
PDF
No ratings yet
CP2 Assignment
8 pages
Java CW Recursive
PDF
No ratings yet
Java CW Recursive
5 pages
Logic For The Assignment Problems
PDF
No ratings yet
Logic For The Assignment Problems
5 pages
Computer Science Project: For Isc Programming in Bluej
PDF
No ratings yet
Computer Science Project: For Isc Programming in Bluej
33 pages
ITCS 111 Final S2 2016 - 2017 - Key
PDF
No ratings yet
ITCS 111 Final S2 2016 - 2017 - Key
6 pages
Rudra D. 100+ Java Programs Examples. Best For Beginners... 2023
PDF
No ratings yet
Rudra D. 100+ Java Programs Examples. Best For Beginners... 2023
66 pages
II Prelim Revision 2024 computer
PDF
No ratings yet
II Prelim Revision 2024 computer
5 pages
Practical Part One
PDF
No ratings yet
Practical Part One
14 pages
Core Java Practical
PDF
No ratings yet
Core Java Practical
51 pages
Chapter 14 Projects
PDF
No ratings yet
Chapter 14 Projects
9 pages
Isc Class Xii Computer Science Project Java Programs
PDF
No ratings yet
Isc Class Xii Computer Science Project Java Programs
77 pages