Itcs 1213 Uncc Final Exam Questions
With Correct Answers
Is bit bpossible bto bcreate ban barray bin bJava bwhere bthe bfirst brow bhas b5 belements,
bthe bsecond brow bhas b6 belements band bthe bthird brow bhas b2 belements? b- bcorrect
banswers✔✔yes
create ba bfor bloop bto bexecute: bIs bit bpossible bto bcreate ban barray bin bJava bwhere bthe
bfirst brow bhas b5 belements, bthe bsecond brow bhas b6 belements band bthe bthird brow
bhas b2 belements? b- bcorrect banswers✔✔double b[] b[] bsalaries b= bnew bdouble
b[NUM_STORES][]; b
array[0] b= bnew bdouble b[5]; b
array[1] b= bnew bdouble b[6]; b
array[2] b= bnew bdouble b[2];
Write bthe bstatement bto bprint bthe bnumber bof belements bin ba bone-dimensional barray.
b- bcorrect banswers✔✔for(i b=0; bi<array.length b-1; bi++)
{
bSystem.out.println(array[i]); b
}
What bdoes bJava binitialize bthe belements bof ban barray bof breferences bto? b- bcorrect
banswers✔✔null
What bdoes bJava binitialize ban barray bof bints bto? b- bcorrect banswers✔✔0
Is ban barray ban bobject? b- bcorrect banswers✔✔Yes
int b[ b] bnumbers b= bnew bint[16] bhow bmany bobjects bwere bcreated? b- bcorrect
banswers✔✔1, bnew bwas bused bonce
Student b[ b] broster b= bnew bStudent[25] b<- bhow bmany bobjects bwere bcreated? b-
bcorrect banswers✔✔1, bnew bwas bused bonce
Write bthe bcommand bto bcompile ba bsource bcode bfile bnamed bBook.java b- bcorrect
banswers✔✔javac bBook.java
, Write bthe bcommand bto brun ba bclass bfile bnamed bBook.class b- bcorrect
banswers✔✔java bBook
Where bdoes bthe bexecution bof ba bJava bproject bbegin? b- bcorrect banswers✔✔public
bstatic bvoid bmain(String b[] bargs)
How bmany bpublic bclasses bcan ba bJava bclass bfile bcontain? b- bcorrect banswers✔✔1
Can byou bdeclare bfields bof ba bclass binside ba bmethod? b- bcorrect banswers✔✔No
What bdoes bprivate baccess bfor ba bfield bmean? b- bcorrect banswers✔✔Only bthe
bcurrent bclass bwill bhave baccess bto bthe bfield bor bmethod.
What bdoes bpublic baccess bfor ba bfield bmean? b- bcorrect banswers✔✔Any bclass bcan
brefer bto bthe bfield bor bcall bthe bmethod.
What bdoes bprotected baccess bfor ba bfield bmean? b- bcorrect banswers✔✔Only bthe
bcurrent bclass band bsub bclasses b(and bsometimes balso bsame-package bclasses) bof
bthis bclass bwill bhave baccess bto bthe bfield bor bmethod.
What bhappens bif byou bdo bnot bspecify bthe baccess bfor ba bfield? b- bcorrect
banswers✔✔It bwill bset bthe baccess bto bpackage
Can ba bsub-class balso bbe ba bsuper-class? b- bcorrect banswers✔✔Yes, bJava ballows
bthis
What bis ban babstract bmethod? b- bcorrect banswers✔✔It bis ba bmethod bthat bis
bdeclared, bbut bcontains bno bimplementation
What bis ban babstract bclass? b- bcorrect banswers✔✔Is ba bclass bthat bis bdeclared
babstract b—it bmay bor bmay bnot binclude babstract bmethods. bAbstract bclasses bcannot
bbe binstantiated, bbut bthey bcan bbe bsub bclassed.
Does ba bsuper bclass bhave bto bbe babstract? b- bcorrect banswers✔✔No
How bmany bclasses bcan ba bclass bdirectly binherit bfrom? b- bcorrect banswers✔✔1
How bmany binterfaces bcan ba bclass bimplement? b- bcorrect banswers✔✔Multiple bor
bunlimited
What bcan ba bJava binterface bcontain? b- bcorrect banswers✔✔Consists bof bmodifiers,
bthe bkeyword binterface, bthe binterface bname, ba bcomma-separated blist bof bparent
binterfaces b(if bany), band bthe binterface bbody
With Correct Answers
Is bit bpossible bto bcreate ban barray bin bJava bwhere bthe bfirst brow bhas b5 belements,
bthe bsecond brow bhas b6 belements band bthe bthird brow bhas b2 belements? b- bcorrect
banswers✔✔yes
create ba bfor bloop bto bexecute: bIs bit bpossible bto bcreate ban barray bin bJava bwhere bthe
bfirst brow bhas b5 belements, bthe bsecond brow bhas b6 belements band bthe bthird brow
bhas b2 belements? b- bcorrect banswers✔✔double b[] b[] bsalaries b= bnew bdouble
b[NUM_STORES][]; b
array[0] b= bnew bdouble b[5]; b
array[1] b= bnew bdouble b[6]; b
array[2] b= bnew bdouble b[2];
Write bthe bstatement bto bprint bthe bnumber bof belements bin ba bone-dimensional barray.
b- bcorrect banswers✔✔for(i b=0; bi<array.length b-1; bi++)
{
bSystem.out.println(array[i]); b
}
What bdoes bJava binitialize bthe belements bof ban barray bof breferences bto? b- bcorrect
banswers✔✔null
What bdoes bJava binitialize ban barray bof bints bto? b- bcorrect banswers✔✔0
Is ban barray ban bobject? b- bcorrect banswers✔✔Yes
int b[ b] bnumbers b= bnew bint[16] bhow bmany bobjects bwere bcreated? b- bcorrect
banswers✔✔1, bnew bwas bused bonce
Student b[ b] broster b= bnew bStudent[25] b<- bhow bmany bobjects bwere bcreated? b-
bcorrect banswers✔✔1, bnew bwas bused bonce
Write bthe bcommand bto bcompile ba bsource bcode bfile bnamed bBook.java b- bcorrect
banswers✔✔javac bBook.java
, Write bthe bcommand bto brun ba bclass bfile bnamed bBook.class b- bcorrect
banswers✔✔java bBook
Where bdoes bthe bexecution bof ba bJava bproject bbegin? b- bcorrect banswers✔✔public
bstatic bvoid bmain(String b[] bargs)
How bmany bpublic bclasses bcan ba bJava bclass bfile bcontain? b- bcorrect banswers✔✔1
Can byou bdeclare bfields bof ba bclass binside ba bmethod? b- bcorrect banswers✔✔No
What bdoes bprivate baccess bfor ba bfield bmean? b- bcorrect banswers✔✔Only bthe
bcurrent bclass bwill bhave baccess bto bthe bfield bor bmethod.
What bdoes bpublic baccess bfor ba bfield bmean? b- bcorrect banswers✔✔Any bclass bcan
brefer bto bthe bfield bor bcall bthe bmethod.
What bdoes bprotected baccess bfor ba bfield bmean? b- bcorrect banswers✔✔Only bthe
bcurrent bclass band bsub bclasses b(and bsometimes balso bsame-package bclasses) bof
bthis bclass bwill bhave baccess bto bthe bfield bor bmethod.
What bhappens bif byou bdo bnot bspecify bthe baccess bfor ba bfield? b- bcorrect
banswers✔✔It bwill bset bthe baccess bto bpackage
Can ba bsub-class balso bbe ba bsuper-class? b- bcorrect banswers✔✔Yes, bJava ballows
bthis
What bis ban babstract bmethod? b- bcorrect banswers✔✔It bis ba bmethod bthat bis
bdeclared, bbut bcontains bno bimplementation
What bis ban babstract bclass? b- bcorrect banswers✔✔Is ba bclass bthat bis bdeclared
babstract b—it bmay bor bmay bnot binclude babstract bmethods. bAbstract bclasses bcannot
bbe binstantiated, bbut bthey bcan bbe bsub bclassed.
Does ba bsuper bclass bhave bto bbe babstract? b- bcorrect banswers✔✔No
How bmany bclasses bcan ba bclass bdirectly binherit bfrom? b- bcorrect banswers✔✔1
How bmany binterfaces bcan ba bclass bimplement? b- bcorrect banswers✔✔Multiple bor
bunlimited
What bcan ba bJava binterface bcontain? b- bcorrect banswers✔✔Consists bof bmodifiers,
bthe bkeyword binterface, bthe binterface bname, ba bcomma-separated blist bof bparent
binterfaces b(if bany), band bthe binterface bbody