Computer Science Test
Questions and Answers
Updated 2026
PrintWriterB-BAnswerBWhatBisBusedBforBwritingBoutputBtoBaBfile?
scannerB-BAnswerBWhatBisBusedBwhenBgettingBinputBfromBaBfile?
scannerB-BAnswerBWhichBofBtheBfollowingBisBnotBaBprimitiveBdataBtype?
floatB
longB
ScannerB
char
/nB-BAnswerBWhichBofBtheBfollowingBisBanBexampleBofBanBescapeBsequence?
/nB
whileB
mainB
Scanner
countB==B1B-
BAnswerBWhichBofBtheBfollowingBdoesBnotBchangeBtheBvalueBofBaBvariable?
count++
countB==B1
countB+=B1
countB=B1
countB=BcountB+B1
, Math.powB-
BAnswerBWhichBofBtheBfollowingBshouldByouBuseBtoBcomputeBtheBvalueBthatBresults
BwhenBraisingBoneBvariableBtoBtheBpowerBofBanotherB(i.e,Bexponentiation)?
Math.powB
Math.random
**B
++
^B
none
okBwillBalwaysBbeBprintedB-
BAnswerBif(BfirstletterB!=B'y'B||BfirstletterB!=B'Y')BSystem.out.printlnB(B"ok"B);
WhichBofBtheBfollowingBtrue:
okBwillBalwaysBbeBprinted
okBwillBneverBbeBprinted
okBwillBbeBprintedBonlyBwhenBfirstletterBisBneitherB'y'BnorB'Y'
theBvalueBofBfirstletterBwillBbeBprintedBonlyBifBitBhasBtheBvalueB'n'
none
TestQuestion.javaB-BAnswerBSupposeByouBimplementBaBclassBwithBtheBheader
B//BpublicBclassBTestQuestion
TheBjavaBsourceBcodeBforBtheBclassBisBstoredBinBaBfileBwithBtheBname:
19B-BAnswerBHowBmanyBtimesBwillBtheBbodyBofBtheBloopBexecute?
forB(intBiB=B1;BiB<B20,Bi++)
{
BSystem.out.printlnB(BiB)
Questions and Answers
Updated 2026
PrintWriterB-BAnswerBWhatBisBusedBforBwritingBoutputBtoBaBfile?
scannerB-BAnswerBWhatBisBusedBwhenBgettingBinputBfromBaBfile?
scannerB-BAnswerBWhichBofBtheBfollowingBisBnotBaBprimitiveBdataBtype?
floatB
longB
ScannerB
char
/nB-BAnswerBWhichBofBtheBfollowingBisBanBexampleBofBanBescapeBsequence?
/nB
whileB
mainB
Scanner
countB==B1B-
BAnswerBWhichBofBtheBfollowingBdoesBnotBchangeBtheBvalueBofBaBvariable?
count++
countB==B1
countB+=B1
countB=B1
countB=BcountB+B1
, Math.powB-
BAnswerBWhichBofBtheBfollowingBshouldByouBuseBtoBcomputeBtheBvalueBthatBresults
BwhenBraisingBoneBvariableBtoBtheBpowerBofBanotherB(i.e,Bexponentiation)?
Math.powB
Math.random
**B
++
^B
none
okBwillBalwaysBbeBprintedB-
BAnswerBif(BfirstletterB!=B'y'B||BfirstletterB!=B'Y')BSystem.out.printlnB(B"ok"B);
WhichBofBtheBfollowingBtrue:
okBwillBalwaysBbeBprinted
okBwillBneverBbeBprinted
okBwillBbeBprintedBonlyBwhenBfirstletterBisBneitherB'y'BnorB'Y'
theBvalueBofBfirstletterBwillBbeBprintedBonlyBifBitBhasBtheBvalueB'n'
none
TestQuestion.javaB-BAnswerBSupposeByouBimplementBaBclassBwithBtheBheader
B//BpublicBclassBTestQuestion
TheBjavaBsourceBcodeBforBtheBclassBisBstoredBinBaBfileBwithBtheBname:
19B-BAnswerBHowBmanyBtimesBwillBtheBbodyBofBtheBloopBexecute?
forB(intBiB=B1;BiB<B20,Bi++)
{
BSystem.out.printlnB(BiB)