0% found this document useful (0 votes)
12 views15 pages

Java MCQ Questions and Answers

This document contains a set of multiple choice questions and answers related to Java programming concepts. The questions cover topics like data types, arrays, loops, objects, packages and more.

Uploaded by

Mosisa Bersisa
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)
12 views15 pages

Java MCQ Questions and Answers

This document contains a set of multiple choice questions and answers related to Java programming concepts. The questions cover topics like data types, arrays, loops, objects, packages and more.

Uploaded by

Mosisa Bersisa
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

Jav

aMCQ(
Mul
ti
pleChoi
ceQuest
ionsandAnswer
)

[Link]
l
esti
ntegert
ypei
s__
___
___andi
tssi
zei
s__
___
___
_bi
ts.

[Link]
t,16

[Link]
t,16

[Link]
te,
8

[Link]
t,8

Answer
:by
te,
8

[Link]
zeoff
loatanddoubl
einJav
ais_
___
___
__

A.32and32

B.32and64

C.64and64

D.64and32

Answer
:32and64
[Link]
choft
hef
oll
owi
ngaut
omat
ict
ypeconv
ersi
onwi
l
lbepossi
ble?

A.i
ntt
olong

[Link]
tet
oint

[Link]
ttoi
nt

D.l
ongt
oint

Answer
:intt
olong

[Link]
omat
ict
ypeconv
ersi
oni
nJav
atakespl
acewhen_
___
___
___
_

[Link]
ypear
ecompat
ibl
eandsi
zeofdest
inat
iont
ypei
slar
gert
hansour
cet
ype

[Link]
ypear
ecompat
ibl
eandsi
zeofdest
inat
iont
ypei
sequal
ofsour
cet
ype

[Link]
ypear
ecompat
ibl
eandsi
zeofdest
inat
iont
ypei
sshor
tert
hansour
cet
ype

[Link]
loft
heabov
e

Answer
:Twot
ypear
ecompat
ibl
eandsi
zeofdest
inat
iont
ypei
slar
gert
hansour
cet
ype
5.I
nJav
a,t
hewor
dtr
uei
s__
___
___
___
___
__

[Link]
eanl
i
ter
al

[Link]
akey
wor
d

[Link]
alue1

[Link]
alue0

Answer
:ABool
eanl
i
ter
al

[Link]
zeofi
nti
nJav
ais_
___
___
___
_

A.64bi
t

B.16bi
t

C.32bi
t

[Link]
ionenv
ironment

Answer
:32bi
t
7.I
nJav
aar
ray
sar
e__
___
___
_

[Link]
imi
ti
vedat
aty
pe

[Link]
ect
s

[Link]
ectr
efer
ences

[Link]

Answer
:obj
ect
s

[Link]
ectf
rom amongt
hef
oll
owi
ngchar
act
erescapecodewhi
chi
snotav
ail
abl
einJav
a.

A.\
t

B.\
r

C.\
a

D.\
\

Answer
:\a
[Link]
oupassanar
rayt
oamet
hod,
themet
hodr
ecei
ves_
___
___
_

[Link]
efer
enceoft
hear
ray

[Link]
hef
ir
stel
ement

[Link]
hear
ray

[Link]
engt
hoft
hear
ray

Answer
:Ther
efer
enceoft
hear
ray

[Link]
choneoft
hef
oll
owi
ngi
sav
ali
dst
atement
?

[Link]
[]c=newchar
[5]
;

[Link]
[]c=newchar
();

[Link]
[]c=newchar
(4)
;

[Link]
[]c=newchar
[]
;

Answer
:char
[]c=newchar
[5]
;
11.I
nJav
aby
te,
shor
t,i
ntandl
ongal
loft
hesear
e__
___
___
___

[Link]
gned

[Link]
gned

[Link]
hA&B

[Link]

Answer
:si
gned

[Link]
choft
hef
oll
owi
ngf
orl
oopswi
l
lbeani
nfi
nit
eloop?

A.f
or(
i=0;
i<1;
i–)

B.f
or(
;

C.f
or(
i=0;
;i++)

[Link]
loft
heabov
e

Answer
:Al
loft
heabov
e
[Link]
ecti
scr
eat
edwi
thnewkey
wor
d__
___
___
___

[Link]
l
e-t
ime

[Link]
hecode

[Link]
un-
ti
me

[Link]
hese

Answer
:Atr
un-
ti
me

[Link]
sacol
l
ect
ionof
___
___
___
_

A.I
nter
faces

[Link]
asses

[Link]
ti
ngt
ool
s

[Link]
assesandI
nter
faces

Answer
:Cl
assesandI
nter
faces
[Link]
imi
ti
vedat
aty
pesar
ether
einJav
a?

A.7

B.8

C.6

D.9

Answer
:8

[Link]
aisa_
___
___
__l
anguage.

[Link]
rongl
yty
ped

[Link]
yty
ped

[Link]
atet
yped

[Link]

Answer
:st
rongl
yty
ped
[Link] hodwi
thi
naclassi
sonlyaccessibl
ebycl
assesthatar
edefinedwi
thinthesame
packageasthecl
assofthemet
[Link] choneoft
hefoll
owingisusedtoenforcesuch
rest
ri
cti
on?

[Link]
aret
hemet
hodwi
tht
hekey
wor
dpr
ivat
e

[Link]
aret
hemet
hodwi
tht
hekey
wor
dpubl
i
c

[Link]
aret
hemet
hodwi
tht
hekey
wor
dpr
otect
ed

[Link]
aret
hemet
hodwi
thanyaccessi
bil
i
tymodi
fi
ers

Answer
:Donotdecl
aret
hemet
hodwi
thanyaccessi
bil
i
tymodi
fi
ers

[Link] hekey
wordthatmakesav
ari
abl
ebel
ongt
oacl
ass,
rat
hert
hanbei
ngdef
inedf
or
eachinst
anceofthecl
ass.

[Link]
ract

[Link]
ati
c

C.f
inal

[Link]
ive

Answer
:st
ati
c
19.t
oSt
ri
ng(
)met
hodi
sdef
inedi
n__
___
___
__

A.j
ava.
lang

B.j
ava.
lang.
uti
l

C.j
ava.
lang.
Str
ing

D.j
ava.
lang.
Obj
ect

Answer
:jav
a.l
ang.
Obj
ect

[Link]
ri
ngmet
hodcompar
eTo(
)ret
urns

A.t
rue

B.f
alse

[Link]
ntv
alue

D.1

Answer
:ani
ntv
alue
[Link]
assst
ri
ngbel
ongst
o__
___
___package.

A.j
ava.
appl
et

B.j
ava.
awt

C.j
ava.
lang

D.j
ava.
str
ing

Answer
:jav
a.l
ang

[Link]
ruct
orSt
ri
ngcl
asshav
e?

A.7

B.13

C.2

D.5

Answer
:13
[Link]
l
lbet
her
etur
nty
peofamet
hodt
hatnotr
etur
nsanyv
alue?

[Link]

[Link]
e

C.v
oid

D.i
nt

Answer
:voi
d

[Link]
sMat
h.f
loor
(3.
6)?

A.4

B.3

C.3.
0

D.4.
0

Answer
:3.
0
[Link]
choft
hef
oll
owi
ngopt
ionsi
sthebestf
orgener
ati
ngr
andom i
nteger0or1?

A.(
int
)Mat
h.r
andom(
)

B.(
int
)Mat
h.r
andom(
)+1

C.(
int
)(Mat
h.r
andom(
)+0.
5)

D.(
int
)(Mat
h.r
andom(
)+0.
2)

Answer
:(i
nt)
(Mat
h.r
andom(
)+0.
5)

26.I
nwhichareaofmemor
y,t
hesy
stem st
orespar
amet
ersandl
ocal
var
iabl
eswhenev
era
methodi
sinvoked?

[Link]
ray

[Link]

[Link]
orageAr
ea

[Link]
ack

Answer
:St
ack
[Link]
inal
i
ze(
)met
hodi
scal
l
edj
ustpr
iort
o__
___
___
___
_

[Link]
ect
,var
iabl
eormet
hodgoesoutofscope

[Link]
oregar
bagecol
l
ect
ion

[Link]
ectorv
ari
abl
egoesoutofscope

[Link]
ari
abl
egoesoutofscope

Answer
:Bef
oregar
bagecol
l
ect
ion

[Link]
mpl
i
citr
etur
nty
peofaconst
ruct
ori
s__
___
___
__

[Link]
eisnor
etur
nty
pe

B.v
oid

[Link]
assobj
ecti
nwhi
chi
tisdef
ined

[Link]

Answer
:Acl
assobj
ecti
nwhi
chi
tisdef
ined
[Link]
ari
abl
esdecl
aredi
nacl
assf
ort
heuseofal
lmet
hodsoft
hecl
assar
ecal
l
ed_
___
___
_

A.i
nst
ancev
ari
abl
es

[Link]
ect
s

C.r
efer
encev
ari
abl
es

[Link]

Answer
:inst
ancev
ari
abl
es

[Link]
choft
hemodi
fi
ercan’
tbeusedf
orconst
ruct
ors?

[Link]
i
c

[Link]
ati
c

[Link]
ivat
e

[Link]
otect
ed

Answer
:st
at

You might also like