0% found this document useful (0 votes)
17 views13 pages

Java 1-8 Question PDF

The document discusses various programming concepts in Java, focusing on object-oriented programming (OOP) principles and data types. It includes examples of code snippets demonstrating the use of variables, methods, and control structures. Additionally, it touches on the importance of data hiding and type casting in Java programming.

Uploaded by

Gagan M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views13 pages

Java 1-8 Question PDF

The document discusses various programming concepts in Java, focusing on object-oriented programming (OOP) principles and data types. It includes examples of code snippets demonstrating the use of variables, methods, and control structures. Additionally, it touches on the importance of data hiding and type casting in Java programming.

Uploaded by

Gagan M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

wlh Java ia

Oopa
ist cut
olitnt ed ptuagomning

Puaglamnnirg
In Puaftual puagkommirg Bn 00p , he puapirn
she divi ded iato dras
into
pegam pat calltd objtob.

* Peiocdsasuageamig tallous
a top-douon appuaeh -ng kolud a bottomup
pplusa ch.
heu
in puendutal puagommig 00p hau Spuiiu

Addirg new dato &


dala &furion
Puscedusal plagonnig Objat dulota puagfomnig
hat hae ony pap uaay
hiding dot a So t cu Tugvider clata hiding ko

Explain tho Ceneepli 00p


)Entaptulaion
thu Mechomitm thot bindu toqeho
Entapalar
eods omol
On

do
w

manipulat u &keps bath daje


Bm Qutsi du indyuene &mis URe
Cn Jaa the bai o encaoton s h clat.
A clow dahine the eate & behovion/ oleta c¡cdu)
dhat w bu Ghascd by du saj eutd .
unt" wtthout
dsioly bakqtaund thin
th to ino Usomtal
ctoncbsta *Deta
chion abtea Doda iN)
bbastue
dutreo bu caM genal
iqu. T itmake hqydliHu
at thou Ony
n to haclinhslitomtt,
om a
cdo'y'aho
'al
which nheutome *
Cnhsuitane i)
enatn lorlod ao
Usd be Com
mthod
, mutiple intuu, auOne
onypt4 Thi&ituation.
w the d
nah Uat the dis¥M
by oauhion apu'
'olymauph'Aus
m
wa
alo thot
mouphiams Poly
methodi. Cald
dato that on y
dufind
by data thutlam. dho
Uaniou duwtwd Jhtodai obitt toth
dod abue hidles (otcin aladaily

s) what ype catingtype


? Convauior)
Eorpe paan. (6
neceMauy to kou a
typt into the vaublevalu onothu yp. tn
&itu tehi'on the that to b doud
tho
typ!. AMigning
hould be Casteo de Hinalionoiable amethes
vau o One typt to a
Known

4. cwidkni ng Cating (Cmplidi)


id’ Jong’ toa ’ douio
’ Shot -’
uwIden

Halo

Eomple!
Pubit clay Tet
Pabie Saht void main (stsu'rgl] at

Out.

plindln ("Foà valu "tf);


dytm. Out
Long Vau: t00
foat valu: (00. 0.
One

(4) tow to diela uut dimei'ona ausay tn


Jona Trompls tth &nplu liomple plaglom
Gyattiors)
whih tases a fized diz dinusrital
Abuay omens thu dam ty p. an
(ollach on daba,
wd to Ddtsu a Calcion om
mau usu to sthink'
but t ç gten Valiablu

Delasung Ausay Vauiobley 'n


in plisgton you mat
a puogha
doelaea vaieble to
you must dpui y the dype aWLay th
Waiabtp lam Luuente. Htud a dytor
dodoi

int myit(]:

naadajo lypel'aaysiz);
Public dtatit Void main

double[)mykii t f1.9, 3.9, 3.43:


Aon Cint i:o; i<3 ; itt)

Output?
|9
).9
34
Wite jawa Puagton
Point uiable

&taie Void main (atubgDany)


Publie
byte b l00.5
Shnt St 15
0.75I;
int i
15186;
long
clouble d
Sydm. thd pritdn (" byde valut b);
Puitn (" dho valu: ):

(" lorg valy :. "4)


(" oa' alu
(" cloubls valu "td);

Output;
te value -

value - |5786
Jong
{loat vale : 159.76
cuouble value- 96.35000 .

lai'n Continuw ond kluak Stuttmds


6) Eap
inJcwa wth bxomple
dol: The buak stat mant i
Contel aut
Thu buak
Wm
buale totimet when you
tmmediat ely to the dtatomt
ts jomp Condliel tthue
tollauing the encdoing
Jabe! & then we th Ja n
buak &tatene
you
în a dlñy nested doap A.
baak
Etample
Tubic caw Exomple e
Publie &latt Void main ( bing (Iasg)i
dut plirntlrn ("alumbs| - to");
++í

oue ak3

Th eoninw dtattment

8xeuion do lNNme at t fop


Op md CauA
&at emt when
do not
Contin
eunnai'ng
you
daemnt in
thu
the loop, bd you do no

ali o pluovid a a doop h a labul b


Veu
Voa Com
yau tontnw dtatemn!
thn ue dhdu labl in
The labd nom u optiona, &us cwually Only
Uou wish to utn to the Qutmoat
wtd whn
in a nutd toopA.
Continu;

Pablie can Ezomple


Puble &i'e Void máin(aing(Jaq)
aystom. but pwintln ('odd Nunbos" )
itt)?
(ontinus
+"lt

3
5

Wite
Owdag! Qmong th elemendi,6,3,3 vig
4ou each Cn Javo. tto w o each is
foh bop
Pubie late Void main
id num[J- fe.6. 2,73:

Sum t= I ;

tladtt avg = Sum/4


pintla

Outputi
Avuoge 5.45r
fo- Eoch Veidn the ou Loop:
talbcion )
&t at ehmond block :
tte.
thu nomu em teuation Vaioble thot wil
ui'ive tu clemin n a colllchion, ong
tt'm buginnig
Authumah't opuajy
with Exomplu
do!The Buie Athimait opuatos:
The odd H'0n, dubtua n mulhpiaD,
diviai0n- al bho ay
nume yp. The minus pUrater ao
O al
that nigatu
opuand.
Eromple
daw Boit math
Pablic tlat Atotie void matn (ating( ag
plirtln ( nty
int a |t|3
in t b a*3
int b)4;
ot d l-a;
lnt = -d
byton. dl. puint("ac" ta):
("b:" tb);
/" )
(°d- "+ d):

Auit mhe.
Th
The mo abud opuat y u n tu Semainden
a diviá'on opuatii,Tt (om h appld to
demon atey Hy' ;

clow oduly
Publie &lat'e void main

düule y 43. 95 :
puint n(" medto " 4+ X%to)
Sytm. bad.

Qutputi
mod
mod (o . 9S

opUahon with om aigmad. Ayou


On aihnithe ollouwin
know, Aot md dk1 he
Rusbabuy
Quiie Ommon i'n Peaghommjn
Clan optgyad f.
Publie stat vod main Awig t ang)

dystom, ut. plid.

nceuont and Dumnt


The t+ ond

Thu incaem ophomel


'by ont. The dum trt opeamd citsuau
on
the opemd ay one.
Exomp'e!
Clous ndec
Publie dtatte Void mai'n (ibing augst)
(nta-|3
tntb

m, Oud. plindln ("a: "ia):


Syttrm. ("b' b) "
peunt n ("c= "+ c):
+d)i

b3
d=t.

You might also like