Professional Documents
Culture Documents
class Employee
SJung nama, D0J
doube golo
Enpheedouble Stuing
Sun
EplyeSungn, double s Stungd )
Sol 5
nam n
DoJ d,
publie void skawData (0A
Sysum.but psint ("EpNome = "+nomet" "Solava"+Solary
DoJ-" +DoJ);
System oub pntin[);
Output
DoJ-1204|96
Emp Object 1: EmpNome =ABC Solas= 100o0oo
Emp Objee a: EmpNom. = CDE Solayp = 200oo00 DOJ- 12/05]96
Salaya 100 000 DoJ 12|06|97
-
EmpNome
Object 3: DEF
Emp
Salay, 200000 Do 1306/96
-
Ermp
0R130b6341
2 Gueoe a ehss otha muhod thot pinh "This is ponuat: elass" and i
ubelass uith anoth Mathod thot punb. Thi is child class". Nou
Cuat am Object t each e tk clos and call
I-method of ponent elass ba objch a pararit clos
method of child class bObject e child class.
3 me thod of pount do b Object ckild cla
imPoudJava. wil
class buntClass
pubie void Pmelhod (1
SystimCLt printlm-("this parunt cln");
extends Paruentclas
class Child Clam
publi void Cmethod)
ched class")
Systom Gut paintin(" This
m Pmethod l)
3
Owtpul
This is Paout ebs
Ths is child class
Ths pouE elos
2027303034+
3.Creoi a class namud 'Memben havina. hi 46llbsung,mimio
4-Addus 5-oloy|
Dola membevs I Name, 9-Age 3-Phone.Number
'podntsolay'
metkiod nomed ushich print, 1olot thu.
Ttolso ha.s a
odd,double s)
double Salon
Member (Stimgm, nt a, Sting ph,, Stirg
publc
nome =n
phoneNumbeL= ph
Oddouss = add
Sala S
public void paintSalasyC1{ is + Salovy);
paimtln ("Saloy o tmember
Systm.oub
20213030344
vold ahow 03
Systum.otut paitNome"+nam + Age"+ 0ge+ Phena, mumbun+
phone-nuwmbur +addus" + adduw
sbing dapant)
add, s);
uptr (na, Ph,
depantment depant
void showit)
Shstem Out. pouintNome. "+mame +Ag+08e + "Phone humben"+
phone-numbeut oddness"+ address)
System.0uk pn Depoxtment "t depatmU
Sys tom out pailn )
/170000, "TT").
n
Momager m-
MaAgex X, 29, "o3 4567891, "daP
R50060 CSE);
e.paintSalay C)5
e. showC:
m. punt Salay);
m.shw) ;
03F3DB034T
Output
Sala of Re membors 10000.o
Name XYz Age 25 hone Nuwmbu 123456789O addouss Udl
Speciali zation TT
Solo o thi membe ' 250000.69
None ZYX Age 2 Phon numbtr 0234561894 adduss dap
Depantnt CSE
20343030344
4. Wu a pmognam to pou o studenis
tho names Creating,a Studnt
class. It no name. s passed while cxeaking om Object of Student cloas,
be
n a m shoud be Dnknown",
0ihanwiS tki nam. shld
TW
bi aohil o u alina OyeStuder
equal to- thi Stina, valu pased
elom
impont java. util.*;
chss Student
Stmna s ynam
public Student (String.)4
mame S
publie Student)4
name unknon
Output
Ma'treyee
unknoOn
3Coneotea closs to bsint d
unlign ond o. choxadm h ro tteds
howwg,the om name. Jsut d6hkrent sann o, tk gun amd
he, ohaxacdo poXailuns
mpont Javo. udy
public clhss sunt
public astaic void moin (Sthi.] ang)i
Bunk obj ne Bink( );
obj. Butn. (1D,'A');
obj. Buintn(CB'5);
3
NUT d fsintn (int a. choc )
Systm. out. pintlnhugen "404 "1t chan a "4c):
void Banbn (ehar C,int a)
Sysbum. oub.pauintln("Chan,s:+c+"\E Takgera+a)
Oupul
Integ is : 1o cha us A
Cha : B Intae us 5
a08T303034+
whieh ane name,age
6Cneate acbssStudent wik thru dotb membeng
ond addness The constnueton of the
class assigns de fault values
nOme as "wnknown", a g n 0 and adneSs as " not available".
I t hos -twd members ith he same nam 'SetInko". Finst method
iw md t h gomee
nas ponamtis for namt and o
twD
which
sheeos the second method tokes thre parometens
neossiqned to name ,
ag amd addness nespec hivel . Buimt the
0m0a 0md addu e |D studails
mpont java util-¥;
elass Student 4
Stung mameaddreSS,
nt ge,
publi ShudentC)
this. name unknown
this-age "9s O
ths addauss " Not Avaulable"
Oupu
is: Not Avoilable
Name is: XYZ Age is: 20 Addness
a073030347
Nmis RMP A is 29 Addu is: Not Avoalobl
Nom is NP t i s : 30 Addu% is: Daf
Addbus is Not Avoi lolds
Nam is Unknon Ae is : 0
Addruvy i o t t oAa
is0
Nom wkmou
A0813030344
7.Cxeott a class i t a mainC) biot tiaos an doject o elas
Encepion únide a T block. Give t i consucton on Fx eupdiam
Fgumt.Catch ik ezeepli umide. a cato elaus
md print h Sbing ovgumunt. Add a tinally claure. ond
pPhuita mwoge te peve you wa. Thu
npa javnrotil-a
impest java. io.FilaNtfoundFxceplign
pbliz alos Main
m AM JAVA
SysmOut.psintln. msg)5
3
publie stádiu vid main (sing C3 ags ) tous
Exeapton
IlSppese hou usu us
dookia tom a t dusoueLo 8File
1 pongmon is wnalle te find l e
thoous neuw FilNotFoumd
3 catoh Excopionl);
(Fillbt Found Ercephon e)
tho new
fraption ( Fil. Not Found);
coteh(Ecepien e))4
Ssam. cut pointl»-(e getMessoge ( ));
inal4
Q021363034
Output
I uill get puinad
ECapliew in ruad "maim" java.lang. Eneepion:Fdi Not
Found a Maim maum
(Moinjava 16)
:
o213030341
oach kub stung *a8 ve
8. tbit. a Javo. pognam te duplacs. s n thefi'e
sbimg, thot smotchu t t aiven ugulan enuni
uplacumunt
lary. deg
I1Ruplaca all thi'fox' with 'cot
Sti newstn stn. pneplaceAu ("ox",
=
"cat"
+st)
Shstim. bupsumtin('Original. Stbing :" +st»);
Sustim out.puntn st);
Nes String:+heN.St str)
Output
Owigmal. StbinaThe quiak bnoion. -fex jumps ove the lartdog
New Strin Th qluick biroon. co jumps ovot hi layadog
a013630344
9.Wth oa java pmognam. to convod al tki chaxodis in a
sbungto 1otoened
impawt fava.uil.t
publi elass Maim
publie sbotic woid main(Stbimg] sgs)
StbinT="EvEg mOmust Ts a FustH
Beinnf;
Sbunaloud-stn a stn.tolLowenlaul),
0
Systum u pxiatln ("Osiginal stung."+ st );
Sytom.out paimtln. (" sbing in LeserCane "4 lecerst );
Oukrpus
Ciginal S bima: EvExy mOment Ts a. Frest
Beainning
Sting in LouweLcase, even moment is tnesh,
a
beginnin
202363034
Jo W a Java. pognam te check ohetkey o. 8'vtn bulahing puseb im th
midd anetkn. ven sbumg lene. mitdle. menms diumes. delsen t
umen et chanelera t the Lst and oigt thAivtn. tulsslaip
wo mou. thami
impontjava.util.*
pblic class Main
pablie broleaw stnIa Middla (stning.1)
Stuing stn Ma be";
in L st.levgtht);
nt mi-posL2
f(L3)
netn-folse
iCLIJ =o) 2)))
(stn.equals (st.substung (mid-pos-4., mid-post
etuwnEua
élse
Tetuuun tolse,
else
petum todse
3
public stdic void main (Stung C] angs)
Moin m new Main
sbing stni "abbbabe a bbbb"
middle
Sycbem.ouk
cubpúntIn("Ts given. Subsbing oppes wm
2013036317
tt0E9E EC98
M
s
19990 oqvqqqo PPu w ddho ngs qns wa
mmoD