益模软件Java笔试题doc.docx
- 文档编号:25467813
- 上传时间:2023-06-09
- 格式:DOCX
- 页数:24
- 大小:19.09KB
益模软件Java笔试题doc.docx
《益模软件Java笔试题doc.docx》由会员分享,可在线阅读,更多相关《益模软件Java笔试题doc.docx(24页珍藏版)》请在冰豆网上搜索。
益模软件Java笔试题doc
益模软件Java笔试题
java笔试题目
QUESTIONNO:
1
1.publicclassTest{
2.publicstaticvoidmain(Stringargs[]){
3.classFoo{
4.publicinti=3;
5.}
6.Objecto=(Object)newFoo();
7.Foofoo=(Foo)o;
8.System.out.println(“i=“+foo.i);
9.}
10.}
Whatistheresult?
A.i=3
B.Compilationfails.
C.AClassCastExceptionisthrownatline6.
D.AClassCastExceptionisthrownatline7.
QUESTIONNO:
2
11.inti=1,j=10;
12.do{
13.if(i++>–j){
14.continue;
15.}
16.}while(ij){
14.break;
15.}
16.j–;
17.}while(++i<5);
18.System.out.println(“i=”+i+”andj=“+j);
Whatistheresult?
A.i=6andj=5
B.i=5andj=5
C.i=6andj=4
D.i=5andj=6
E.i=6andj=6
QUESTIONNO:
7
1.classSuper{
2.publicfloatgetNum(){return3.0f;}
3.}
4.
5.publicclassSubextendsSuper{.
7.}
Whichmethod,placedatline6,causescompilationtofail?
A.publicvoidgetNum(){}
B.publicvoidgetNum(doubled){}
C.publicfloatgetNum(){return4.0f;}
D.publicdoublegetNum(floatd){return4.0d;}
QUESTIONNO:
8
Whichstatementistrue?
A.catch(Xx)cancatchsubclassesofX.
B.TheErrorclassisaRuntimeException.
C.AnystatementthatcanthrowanErrormustbeenclosedinatryblock.
D.AnystatementthatcanthrowanExceptionmustbeenclosedinatryblock.
E.AnystatementthatcanthrowaRuntimeExceptionmustbeenclosedinatry
block.
QUESTIONNO:
9
Whichthreeformpartofcorrectarraydeclarations?
(Choosethree)
A.publicinta[]
B.staticint[]a
C.public[]inta
D.privateinta[3]
E.privateint[3]a[]
F.publicfinalint[]a
QUESTIONNO:
10
1.publicclassFoo{
2.publicstaticvoidmain(String[]args){
3.try{
4.return;
5.}finally{
6.System.out.println(“Finally”);
7.}
8.}
9.}
Whatistheresult?
A.Finally
B.Compilationfails.
C.Thecoderunswithnooutput.
D.Anexceptionisthrownatruntime.
QUESTIONNO:
11
Given:
ClassOne.java:
1.packagecom.abe.pkg1;
2.publicclassClassOne{
3.privatecharvar=‘a’;
4.chargetVar(){returnvar;}
5.}
ClassTest.java:
1.packagecom.abe.pkg2;
2.importcom.abc.pkg1.ClassOne;
3.publicclassClassTestextendsClassOne{
4.publicstaticvoidmain(String[]args){
5.chara=newClassOne().getVar();
6.charb=newClassTest().getVar();
7.}
8.}
Whatistheresult?
A.Compilationfails.
B.Compilationsucceedsandnoexceptionsarethrown.
C.Anexceptionisthrownatline5inClassTest.java.
D.Anexceptionisthrownatline6inClassTest.java.
QUESTIONNO:
12
Given:
1.classTestA{
2.TestBb;
3.TestA(){
4.b=newTestB(this);
5.}
6.}
7.classTestB{
8.TestAa;
9.TestB(TestAa){
10.this.a=a;
11.}
12.}
13.classTestAll{
14.publicstaticvoidmain(Stringargs[]){
15.newTestAll().makeThings();
16.//…codecontinueson
17.}
18.voidmakeThings(){
19.TestAtest=newTestA();
20.}
21.}
Whichtwostatementsaretrueafterline15,beforemaincompletes?
(Choosetwo)
A.Line15causesastackoverflow.
B.Anexceptionisthrownatruntime.
C.Theobjectreferencedbyaiseligibleforgarbagecollection.
D.Theobjectreferencedbybiseligibleforgarbagecollection.
E.Theobjectreferencedbyaisnoteligibleforgarbagecollection.
F.Theobjectreferencedbybisnoteligibleforgarbagecollection.
QUESTIONNO:
13
Given:
1.publicclassReturnIt{
2.returnTypemethodA(bytex,doubley){
3.return(long)x/y*2;
4.}
5.}
WhatisthenarrowestvalidreturnTypeformethodAinline2?
A.int
B.byte
C.long
D.short
E.float
F.double
QUESTIONNO:
14
Given:
1.publicclassOuterClass{
2.privatedoubled1=1.0;
3.//insertcodehere
4.}
Whichtwoarevalidifinsertedatline3?
(Choosetwo)
A.staticclassInnerOne{
publicdoublemethoda(){returnd1;}
}
B.staticclassInnerOne{
staticdoublemethoda(){returnd1;}
}
C.privateclassInnerOne{
publicdoublemethoda(){returnd1;}
}
D.protectedclassInnerOne{
staticdoublemethoda(){returnd1;}
}
E.publicabstractclassInnerOne{
publicabstractdoublemethoda();
}
QUESTIONNO:
15
Given:
1.publicabstractclassTest{
2.publicabstractvoidmethodA();
3.
4.publicabstractvoidmethodB()
5.{
6.System.out.println(“Hello”);
7.}
8.}
Whichtwochanges,independentlyapplied,allowthiscodetocompile?
(Choosetwo)
A.AddamethodbodytomethodA.
B.Replacelines5–7withasemicolon(“;”).
C.RemovetheabstractqualifierfromthedeclarationofTest.
D.RemovetheabstractqualifierfromthedeclarationofmethodA.
E.RemovetheabstractqualifierfromthedeclarationofmethodB.
QUESTIONNO:
16
Given:
1.interfaceBeta{}
2.
3.classAlphaimplementsBeta{
4.StringtestIt(){
5.return“Tested”;
6.}
7.}
8.
9.publicclassMain1{
10.staticBetagetIt(){
11.returnnewAlpha();
12.}
13.publicstaticvoidmain(String[]args){
14.Betab=getIt();
15.System.out.println(b.testIt());
16.}
17.}
Whatistheresult?
A.Tested
B.Compilationfails.
C.Thecoderunswithnooutput.
D.Anexceptionisthrownatruntime.
QUESTIONNO:
17
Given:
1.publicclassExceptionTest{
2.classTestExceptionextendsException{}
3.publicvoidrunTest()throwsTestException{}
4.publicvoidtest()/*PointX*/{
5.runTest();
6.}
7.}
AtPointXonline4,whichcodeisnecessarytomakethecodecompile?
A.Nocodeisnecessary.
B.throwsException
C.catch(Exceptione)
D.throwsRuntimeException
E.catch(TestExceptione)
QUESTIONNO:
18
Giventhatbandcrefertoinstancesofwrapperclasses,whichtwostatementsare
true?
(Choosetwo)
A.b.equals(b)returnstrue.
B.b.equals(c)returnsthesameresultasb==c.
C.b.eqials(c)canreturnfalseevenifc.equals(b)returnstrue.
D.b.equals(c)throwsanexceptionifbandcaredifferentwrappertypes.
E.b.equals(c)returnsfalseifthetypeofwrapperobjectsbeingcomparedare
different.
QUESTIONNO:
19
Given:
11.try{
12.if((newObject))(.equals((newObject()))){
13.System.out.println(“equal”);
14.)else{
15.System.out.println(“notequal”);
16.}
17.}catch(Exceptione){
18.System.out.println(“exception”);
19.}
Whatistheresult?
A.equal
B.notequal
C.exception
D.Compilationfails.
QUESTIONNO:
20
Given:
1.classBaseClass{
2.privatefloatx=1.of;
3.protectedfloatgetVar(){returnx;}
4.}
5.classSubClassextendsBaseClass{
6.privatefloatx=2.Of;
7.//insertcodehere
8.}
Whichtwoarevalidexamplesofmethodoverridingwheninsertedatline7?
(Choose
two)
A.floatgetVar(){returnx;}
B.publicfloatgetVar(){returnx;}
C.publicdoublegetVar(){returnx;}
D.protectedfloatgetVar(){returnx;}
E.publicfloatgetVar(floatf){returnf;}
QUESTIONNO:
21
Given:
1.publicclassSyncTest{
2.privateintx;
3.privateinty;
4.privatesynchronizedvoidsetX(inti){x=i;}
5.privatesynchronizedvoidsetY(inti){y=i;}
6.publicvoidsetXY(inti){setX(i);setY(i);}
7.publicsynchronizedbooleancheck(){returnx!
=y;}
8.}
Underwhichconditionwillcheckreturntruewhencalledfromadifferentclass?
A.checkcanneverreturntrue.
B.checkcanreturntruewhensetXYiscalledbymultiplethreads.
C.checkcanreturntruewhenmultiplethreadscallsetXandsetYseparately.
D.checkcanreturntrueonlyifSyncTestischangedtoallowxandytobeset
separately.
QUESTIONNO:
22
Given:
1.publicclassXimplementsRunnable{
2.privateintx;
3.privateinty;
4.
5.publicstaticvoidmain(String[]args){
6.Xthat=newX();
7.(newThread(that)).start();
8.(newThread(that)).start();
9.}
10.
11.publicvoidrun(){
12.for(;;){
13.synchronized(this){
14.x++;
15.y++;
16.}
17.
System.out.println(Thread.currentThread().getName()+
18.“x=“+x+“,y=“+
y);
19.}
20.}
21.}
Whatistheresult?
A.Compilationfails.
B.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameon
thesameline(forexample,“x=2,y=1”).
C.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesame
line(forexample,“x=1,y=1”).
Inaddition,eachvalueappearsonlyonce(forexample,“x=1,y=1”followed
by“x=2,y=2”).
Thethreadnameatthestartofthelineshowsthatboththreadsareexecuting
concurrently.
D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesame
line(forexample,“x=1,y=1”).
Inaddition,eachvalueappearsonlyonce(forexample,“x=1,y=1”followed
by“x=2,y=2”).
Thethreadnameatthestartofthelineshowsthatonlyasinglethreadisactually
executing.
QUESTIONNO:
23
Given:
1.//PointX
2.publicclassfoo{
3.publicstaticvoidmain(String[]args)throwsException{
4.jave.io.PrintWriterout=newjave.io.PrintWriter(
5.newjave.io.OutputStreamWriter(System.out),true);
6.out.println(“Hello”);
7.}
8.}
WhichstatementatPointXonline1isrequiredtoallowthiscodetocompile?
A.Nostatementisrequired.
B.importjave.io.*;
C.includejava.io.*;
D.importjave.io.PrintWriter;
E.includejava.io.PrintWriter;
QUESTIONNO:
24
Whichtwoarevaliddeclarationsofafloat?
(Choosetwo)
A.floatf=1F;
B.floatf=1.0.;
C.floatf=‘1’;
D.floatf=“1”;
E.floatf=1.0d;
QUESTIONNO:
25
Whatisthenumericalrangeofachar?
A.0…32767
B.0…65535
310–035
LeadingthewayinITtestingandcertificationtools,
-65-
C.–256…255
D.–32768…32767
E.Rangeisplatformdependent.
QUESTIONNO:
26
Whichcodedeterminestheintvaluefooclosestto,butnotgreaterthan,a
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 软件 Java 笔试 doc
![提示](https://static.bdocx.com/images/bang_tan.gif)