0% found this document useful (0 votes)
23 views7 pages

Core 5 Practical

The document contains Java programming code examples for various tasks, including converting decimal numbers to hexadecimal, octal, and binary formats, as well as generating prime numbers between 4 and 1000. It also demonstrates concepts like exception handling and method overriding. Additionally, it includes examples of Fibonacci series generation and the use of interfaces in Java.
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)
23 views7 pages

Core 5 Practical

The document contains Java programming code examples for various tasks, including converting decimal numbers to hexadecimal, octal, and binary formats, as well as generating prime numbers between 4 and 1000. It also demonstrates concepts like exception handling and method overriding. Additionally, it includes examples of Fibonacci series generation and the use of interfaces in Java.
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/ 7
~ Come-S Cs ttHons) t.torbte a progeary Java to accopt an posbetre Pnbo ere Member frcom the User ano} eedverct Bhat meunber nto Ockals bkrarey ano| heanclee&mal members + Ans: : Class Convert f Seannex Sean y fre mum; Volo} qeevele ) System: out pebrttn(" Deelmal to HenaDecfinal,Oebal and BEnany” Scan =new Scannen (system. fn); } Sesto « Sub pedntin ( “\0 Enton the mumloer : "pe ; Mem = Doteger- paxsednt ( Sean. neaéltne cy), i vob convert ¢ { String hea = Integer . toHexstenatnen); System. Outs prértln C“ Henaner kml Value +” thera), String OCtab= Tnteger. HO ckal Stnk; Crum) 5 - System. oue-préntin( “Octal value & + + ockat) ; Str2og boron > Dotegor . foBtnans/ Sting (nus), Sqstem. Oue+ prfhttn (e Bihacy Value O22 4 trance); 3 Class Deebrrat —Conversfon $ Publle statle volo| malin ( Strboy angst J) 5 convert obf= new Convert e Mgovins Obj. qetvale ; } 2 Obj. Convert ); Output + . f Javac Decfmat -conversfon + Java $ Java Dechmat-converslon Declmat to HexaDectmaly ela ano) racy Enter the number ! aa4 HeroDeckmat value ts 179 Oc€at Value ce 2174 MErareey Value est 4142004 (2) wrdee a PRogeem fy Java to ffro} prfme murmbere § Letween 4 bo 1000+ Anes A2lacs PréimeNumbers spubl[e statte vobo| eroabn ( StrePog anqsl 3) ‘ ent €n0; Ent num= 05 Strbng primenlembers =“. "5 for ( t=15 Ee = 1000; E+ t) § Ent counter = 05 - fon (rum o3 mum >= 45 mem 7) EC Ep mum = =0) Counter = Countet +43 Ef C countem = =2) ‘ prémenlumbers = prfmeNumber+ E+ "5 9 7 5 A System. out sprfottn C8 pebmenlumbers from 4 £0 1000, ane 2”), System. out + prfntien ( premedlumberes % } 3 Oeetpeet + : ; ih Grime Numbers from 1 £0 1000 ace t 23ST 14 13.17 19 23 24 31.37 443 UT SR 54 6167 71:73 TA FB Bq QT Nor 163 107 104 WS INT 131137 139 149 Ist 157 163 > 13 ao71 263 353 367 us7 46s 563 ou 174 181 141 193 197 194 al 293 ANT 29q- 233 23424 AST Q64 A ATT gel aB3 aga 307 gn 313 317 33! 337347 344 373 379 283 384 Bq7 Yor 4oqu4a Yor Yar 433 434 4U3 444 463 4o7 474 «UST Yo 494 Sd3 S0q Sal SAB S4H'SU7T 557 564 S11 577 597 593 54q G01 607 613 GIF GIT BGI sur 643 653 657 G61 673 677 6B% Gar “Io 704 TA TI 733 734 743 S| 357 7161 164 773 187 797 Bq SI B21 s2a B27 329 23q 853 S57 859 $63 877 eel Bes BSF FCT AN AF 424 937 44 BHT 953 47 971 477 9%3 4a! 9qq © weber a preqcam be extend an Enterface Onto another interface anol Emplement all the methoas as perc tour chef Apts ‘nterface A § 3 enterface nm ematenols ‘A j Nobo} funcBt ); . : ae 3 Claes C Emptoments BR 5 vk funche >; Preble volo} furcit ) Scystem + Out “prErtin C“ Tée fs Funch”), } Publle Vek fence i 3 a "peblée class Demo Sepstom, eee prbrebn( “thes & FeeneB") 5 Public Stable Vok) amalh CStrefing angsc ap) sof C obj = new C0), Obj. funcac); Obj. Funeacys ; Output * “hes & feened “Thee & funeB ~ ® werfte a poem to olemonsérate Tetobontg ano} eanboatng . Arst 1] Java proyrar fo Uustrate ‘the Coneept - MH Of Prusoboafny ano} Unbeoding x gostnad 7 Denoting wostbees| atasces Emmport Java fo* * 5 1 makn etass Class GFG f Males oleBreic'nothoo pent’ SCatlc! yoko} «mnaln CStnBog angst a) 5 Y cronebney an Tntegen Object 1 with custom Value. ‘Sar & be do Antoyer = mew Dreaqeee10)5” 7] Unboreine| ane, Object fe O42 = bs HM prént Statements Seystern Ott petnttn C* Value of es” 48); System cue: préntcln c Value of 43" 4 +e); ty nudeboadng of Chacaker Chacaeter YY = “als H Auto~ untooing, oF Chacattere Chor Ch = 4 c Y print Statements ' Sesto Ouke prénetn CS value of eh +” + eh); System: cute prentin(® Value of #4 4 "+4PD; 3 i Output ¢ Nalue of €: 40 Value of €4: 140 Value of tht a Value of yi ® wrete oa PRogtarm wo genetate a flhenacc? soxtos og Mumberes, where the Mme wit be, mecefveo ~from the user. Ayes Empont fava ubtl: Scanner 5 Prblec elass CoolesCnackern f . . Purbtee state volo} emaln ( Serbo CJ ange) ent: A=0, b= 4, C=0,n3 ot Stannen = new Seannege C System.Eny; . Scistem tuts prcdse ( Entox tne. value of 03”) ME SemexkIntly; System * Ott: prént (* \n FRbonacet Sefer oat # tbe +), > ; 3 + C= ath; Na n-a; Whee Cm >07 4 System. gut. prot c+ * ay A=b; bees C= Ath} no=5 ; } ee) ‘ Suiny 3 Po Output + Entex the value of yn: 40 Febonace? Serkes: 044935 ¢ 19 2134 6) Worite a Preqram ko clemonstrate exceptfon eS ce. antthmerte type ence pifons with meatelpte catch Anse pubdte class MecttfpteCatchBtoens: i purbtfe stale veka math ( Sting ong c1) § f, , tnt aC = nev eC]; ects] = 30/0 ; q cateh( AicithmettcExcepeton ey ; Sestem -euksprbntin( * AeBthrreke Enweptten teecans ; s catehl Arrear(TrolenDut lf Boano|sEmeeptton e) f Sqston -cut-pebntin( *drcagPnstenQutOreounds Except lon beeeues »; 7 Catch (Exceptton e) § ee our préntin(S parent Exeepttorn eeecses > 7 Sytem: Cub peintl C'est of the cocfe.”),. Qubput + Ardthmebic Exeeptton dcetrs west Of the Cade

You might also like