英文 SCJP 模拟题200道附答案Word文档格式.docx
- 文档编号:17836145
- 上传时间:2022-12-11
- 格式:DOCX
- 页数:48
- 大小:39.58KB
英文 SCJP 模拟题200道附答案Word文档格式.docx
《英文 SCJP 模拟题200道附答案Word文档格式.docx》由会员分享,可在线阅读,更多相关《英文 SCJP 模拟题200道附答案Word文档格式.docx(48页珍藏版)》请在冰豆网上搜索。
2)%large
3)$fred
4)Integer
5)2much
Q5Whichofthefollowingarecorrectwaystocreateafont.
1)Fontf=newFont("
Serif"
Font.BOLD,24);
2)Fontf=newFont(Font.SERIF,"
Bold"
24);
3)Fontf=newFont("
"
4)Fontf=newFont(Font.SERIF,Font.BOLD,24);
Q6Selectthecorrectstatementsregardingthefollowingpieceofcode.
Filef=newFile("
c:
\\large.txt"
);
1)Onexecution,afilecalled"
large.txt"
willbecreatedonthelocalharddisk.
2)ThecodefailstocompileonaUNIXmachine,becausethedirectoryseparatorisnotcorrect.
3)AfileisNOTcreatedontheharddiskwhenthiscodeisexecuted.
4)Anexceptionisthrownatruntimeifthefile"
alreadyexists.
5)Thecodefailstocompile,sincethisisnotavalidconstructorfortheFileclass.
Q7WhichofthefollowingstatementsarecorrectregardingtheRandomAccessFileclass?
1)AnIOExceptionisthrownifthespecifiedfiledoesn'
texistwhencreatedusingthe"
r"
mode.
2)Thisclasshasamethodwhichallowsafiletobedeletedfromtheharddisk.
3)ItispossibletousethisclassinconjunctionwiththeDataInputStreamclass.
4)Whenusedwiththe"
rw"
mode,thespecifiedfileiscreatedonadiskdrive,ifitdoesn'
talreadyexist.
5)Therearemethodstoreadandwriteprimatives(eg,readInt(),writeInt(),etc).
Q8Considerthefollowingpieceofcodeandselectthecorrectstatementfromthefollowing.
1.Strings=newString("
abcdefgh"
2.s.replace('
d'
'
q'
3.System.out.println(s);
1)Thecodefailstocompile,reportinganerroratline2.Stringsareimmutable,andthereforeareplace()methodismeaningless.
2)Thecodecompilescorrectly,anddisplaysthetext"
abcqefgh"
.
3)Thecodecompilescorrectly,anddisplaysthetext"
4)Thecodecompiles,butanexceptionisthrownwhenline2isexecuted.
5)Thecodecompiles,butanexceptionisthrownatline3.
Q9Whichofthefollowingkeywordscanbeappliedtothevariablesormethodsofaninterface.
1)static
2)private
3)synchronised
4)protected
5)public
Q10TrueorFalse.
OnlyFramescancontainmenubarsorpull-downmenus.
1)True
2)False.
Q11Considerthefollowingpieceofcodeandselectthecorrectstatement(s):
1.classA{
2.protectedintmethod(){
3.}
4.}
5.
6.classBextendsA{
7.intmethod(){
8.}
9.}
1)Thecodefailstocompile,becauseyoucan'
toverrideamethodtobemoreprivatethanitsparent.
2)Thecodefailstocompile,becausemethod()isdeclaredasprotected,andisthereforenotavailabletoanysubclass.
3)Thecodecompilescorrectly,butthrowsaNullPointerExceptionatruntime.
4)Thecodefailstocompile.However,itcanbemadetocompilecorrectlybyprefixingline7withtheaccessqualifier"
public"
5)Thecodefailstocompile.However,itcanbemadetocompilecorrectlybyprefixingline7withtheaccessqualifier"
protected"
Q12TrueorFalse.
TheThrowableclassisthesuperclassofallexceptionsintheJavalanguage.
2)False
Q13Considerthefollowingpieceofcode(assumetheGraphicscontextgisdefinedcorrectly):
g.setBackground(Color.red);
g.setForeground(Color.white);
g.drawLine(10,10,50,10);
g.setForeground(Color.blue);
g.drawRect(100,100,50,50);
Whatisdisplayedwhenthiscodeisexecuted.
1)Abluelinefrom(10,10)to(50,10)andabluerectanglewithupperleftcornerat(100,100).
2)Awhitelinefrom(10,10)to(50,10)andabluesquarewithtopleftcornerat(100,100).
3)Awhitelinefrom(10,10)to(10,50)andabluesquarewithlowerleftcornerat(100,100).
4)Aredlinefrom(10,10)to(50,10)andaredsquarewithupperleftcornerat(100,100).
5)Nothingisdisplayed.Youmustfirstissuearepaint()command.
Q14Considerthefollowingpieceofcode.
classTest{
publicstaticvoidmain(String[]args){
System.out.println(args[3]);
}
Whenthefollowingistypedatthecommandline,whatisdisplayed:
javaTestMetallicaJusticeForAll
1)All
2)For
3)Justice
4)Nothing.
5)Nothing.AnArrayIndexOutOfBoundsExceptionisthrown
Q15Considerthefollowingpieceofcode.
1.Strings="
abcd"
;
2.Integerx=newInteger(3);
3.Strings2=s+4;
4.s2=null;
5.s=null;
Followingtheexecutionofwhichlineabove,istheobjectreferencedbys2availableforgarbagecollection.
1)Line5
2)Itisnotpossibletosaywhenanobjectisavailableforgarbagecollection.
3)Line4
4)Theobjectsarenotavailableuntiltheexecutingthreadisended.
Q16Whatisdisplayedwhenthefollowingpieceofcodeiscompiledandexecuted:
Baseb=newSubclass();
System.out.println(b.x);
System.out.println(b.method());
classBase{
intx=2;
intmethod(){
returnx;
classSubclassextendsBase{
intx=3;
1)Nothing.Thecodefailstocompilebecausetheobjectbisnotcreatedinavalidway.
2)2
3
3)2
2
4)3
5)3
Q17Whatisdisplayedwhenthefollowingisexecuted:
Strings1="
aaa"
s1.concat("
bbb"
System.out.println(s1);
1)Thestring"
2)Thestring"
aaabbb"
3)Nothing.concat()isnotavalidmethodintheStringclass.
4)Thestring"
bbbaaa"
5)Thestring"
Q18TrueorFalse.
ThefollowingisavalidwaytoconstructaStringBuffer.
StringBuffersb1="
Q19Whatistheoutputofthefollowingpieceofcode:
1.intx=6;
2.doubled=7.7;
3.
4.System.out.println((x>
d)?
99.9:
9);
1)9
2)9.0
3)99.9
4)Nothing.AnArithmeticExceptionisthrownatline4.
5)6
Q20Whichofthefollowingcanbeputinapplettags?
(selectallthecorrectanswers)
1)CODE
2)WIDTH
3)HEIGHT
4)PARAM
5)ARCHIVE
Q21Whatisprintedoutfollowingtheexecutionofthecodebelow:
1.classTest{
2.staticStrings;
3.publicstaticvoidmain(String[]args){
4.intx=4;
5.if(x<
4)
6.System.out.println("
Val="
+x);
7.else
8.System.out.println(s);
10.}
Nothing.ThecodefailstocompilebecausetheStringsisn'
tdeclaredcorrectly.
1)Thetext"
Val=null"
isdisplayed.
3)Thetext"
null"
4)Ablanklineoftextisprinted.
Q22TrueorFalse.
TheStringBufferclassdoesnothaveaconcat()method.
Q23Whatisdisplayedwhenthefollowingpieceofcodeisexecuted(assumethegraphicscontext,g,iscorrectlysetup):
g.drawString("
abc"
10,10);
withthelowerleftpartof"
a"
locatedatx=10,y=10.
2)Thetext"
withtheupperleftpartof"
3)Nothing.Thisisnotavalidmethod.
Q24TrueorFalse.
Anonymousclassescannothaveconstructors.
Q25ToreferenceaJARfromawebpage,whichofthefollowingkeywordsareused:
1)jar
2)class
3)zip
4)archive
5)package
Q26
Analysethefollowing2classesandselectthecorrectstatements.
classA{
privateintx=0;
staticinty=1;
protectedintq=2;
classBextendsA{
voidmethod(){
System.out.println(x);
System.out.println(y);
System.out.println(q);
1)ThecodefailstocompilebecausethevariablexisnotavailabletoclassB.
2)Thecodecompilescorrectly,andthefollowingisdisplayed:
012
3)Thecodefailstocompilebecauseyoucan'
tsubclassaclasswithprivatevariables.
4)Removingtheline"
System.out.println(x)"
willallowthecodetocompilecorrectly.
5)ThecompilerwillcomplainthatthevariablexinclassBisundefined.
Q27Whichofthefollowinginterfacescanbeusedtomanageacollectionofelements,withnoduplication.
1)List
2)Vector
3)Set
Q28Whichofthefollowingstatementsaretrueregardinginnerclasses.
1)Variablesdefinedinsideinnerclassescannotbestatic.
2)Variablesdefinedinsideinnerclassescannotbestaticunlesstheinnerclassitselfisstatic.
3)Non-staticinnerclasses(whicharenotdefinedinamethod)haveaccesstoallclassandinstancevariables,regardlessoftheaccessqualifierofthosevariables.
4)Aninnerclasscanactuallybeasubclassoftheouterclass
5)Innerclassescanbedeclaredasprivate.Toplevel,outerclassescannot.
Q29Whichofthefollowingarevalidwaystodefineanabstractmethod.
1)abstractvoidTest();
2)abstractvoidTest(){}
3)staticabstractvoidTest();
4)finalabstractvoidTest();
5)Methodscannotbedefinedasabstract,onlyvariablescanbeabstract.
Q30Considerthefollowing:
classAextendsInteger{
intx=0;
Selectallvalidstatements.
1)Thecodewillcompilecorrectly.
2)ThecodewillnotcompilebecauseIntegerisfinalandcannotbesubclassed.
3)ThecodewillnotcompilebecauseclassAhasnomethodsorconstructor.
4)Thecodewillcompile
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 英文 SCJP 模拟题200道附答案 模拟 200 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)