A.6
B.7
C.8
D.10
第1题:
A.y=5
B.y=6
C.y=7
D.y=8
E.编译失败
F.运行时异常被抛出
第2题:
A.z=42
B.z=44
C.z=45
D.z=46
第3题:
A.y=10,x=5
B.y=11,x=6
C.y=12,x=7
D.y=11,x=7
第4题:
A.7
B.8
C.10
D.12
第5题:
A.finished
B.Compilationfails.
C.AnAssertionErroristhrownandfinishedisoutput.
D.AnAssertionErroristhrownwiththemessage“assertionfailed”.
E.AnAssertionErroristhrownwiththemessage“assertionpassed”.
第6题:
执行下列程序之后,变量n的值为( )。 publicclassExam{ publicstaticvoidmain(String[]args){ inty=2; intz=3; intn=4; n=n+-y*z/n; System.out.println(n); } }
A.3
B.-1
C.-12
D.-3
第7题:
有如下程序: #include<iostream> usingnamespacestd; voidf1(int&X,int&y){intz=x;x=y;y=z;}voidf2(intX,inty){intz=x;x=y;y=z;}intmain(){ intx=10,y=26; f1(x,y); f2(x,y); cout<<y<<endl; return0; } 运行时的输出结果是( )。
A.10
B.16
C.26
D.36
第8题:
有下列程序: #include<stdi0.h> intf(intx) { inty; if(x==0‖x==1)return(3); y=x*x-f(X-2); returny; } voidmain( ) { intZ; z=f(3);printf("%d\n",z); } 程序的运行结果是( )。
A.0
B.9
C.6
D.8
第9题:
class Foo { public static void main(String [] args) { int x = 0; int y = 4; for(int z=0; z 〈 3; z++, x++) { if(x 〉 1 & ++y 〈 10) y++; } System.out.println(y); } } 结果是什么?()
第10题:
class Test2{ public static void main(String [] args){ boolean x=true; boolean y=false; short z=42; if((x==true)&&y=true))z++; if((y==true||++z=44))z++; System.out.println(“z=”+z); } } 结果是什么?()
第11题:
Which two code fragments are most likely to cause a StackOverflowError?()
第12题:
7
8
10
12
第13题:
A.z=42
B.z=43
C.z=44
D.z=45
E.编译失败
F.运行的时候有异常抛出
第14题:
A.x=2
B.x=5
C.x=6
D.编译失败
第15题:
A.3
B.5
C.编译失败
D.运行时异常被抛出
第16题:
A.Z=42
B.z=44
C.Z=45
D.z=46
第17题:
A.finished
B.Compilationfails.
C.AnAssertionErroristhrown.
D.AnAssertionErroristhrownandfinishedisoutput.
Thisquestionisabittrickybecauseitlacksthefollowinginformation:Itshouldincludeastatementthatsayswhetherornotassertionsareenabled.Iftheyareindeedenabled,the
correctionanswerisC.butiftheyarenot,thecorrectanswerisA.Assertionsarenotenabledbydefaultsoifthequestionisnotchanged,themostlogicalanswerisA.
第18题:
有如下程序: #included<iostream> usingnamespacestd; voidfl(int&X,int&y){intz=x;x=y;y=z;)voidf2(intX,inty){intz=x;x=y;y=z;}intmain( ){ intx=10,y=26; f1(X,y); f2(x,y); cout<<y<<endl; return0; } 运行时的输出结果是( )。
A.10
B.16
C.26
D.36
第19题:
有下列程序:
#include<stdi0.h>
intf(intx)
{
inty;
if(x==0‖x==1)return(3);
y=x*x-f(X-2);
returny;
}
voidmain( )
{
intZ;
z=f(3);printf("%d\n",z);
}
程序的运行结果是( )。
A.0
B.9
C.6
D.8
第20题:
给定java代码如下所示,在A处新增下列( )方法,是对cal方法的
重载
publicclassTest
{
publicvoidcal(intx,inty,intz)
{
}
//A
}
A.publicintcal(intx,inty,floatz){return0;}
B.publicintcal(intx,inty,intz){return0;}
C.publicvoidcal(intx,intz){}
D.publicviodcal(intz,inty,intx){}
第21题:
现有: class Foo { public static void main (String [] args) { int x=O; int y=4; for (int z=0; z<3; Z++; X++) { if(x>1&++y<10) y++; } System. out .println (y); } } 结果是什么?()
第22题:
class Test4 { public static void main(String [] args) { boolean x = true; boolean y = false; short z = 42; if((z++ = = 42) && (y = true)) z++; if((x = false) || (++z = = 45)) z++; System.out.println("z = " + z); } } 结果为:()
第23题:
z = 42
z = 44
z = 45
z = 46