A.cout << x;
B.cout << y;
C.cout << z;
D.cout << a;
第1题
class Loop{
public static void main(String[] agrs) {
int x=0;int y=0;
outer:
for(x=0;x<100;x++){
middle:
for(y=0;y<100;y++){
System.out.println("x="+x+"; y="+y);
if(y==10){<<>>}
}
}
}
}
在<<>>处插入什么代码可以结束外循环?
A.continue middle;
B.break outer;
C.break middle;
D.continue outer;
E.none of these
第2题
A.passedstuff
B.stuffpassed
C.passed AnAssertionErroristhrownwiththeword“stuff”addedtothestacktrace.
D.passed AnAssertionErroristhrownwithouttheword“stuff”addedtothestacktrace.
E.passed AnAssertionExceptionisthrownwiththeword“stuff”addedtothestacktrace.
F.passed AnAssertionExceptionisthrownwithouttheword“stuff”addedtothestacktrace.
第3题
A.编译失败
B.-42--1234--7.0-
C.-42--1234--7.0-
D.-42--12345--7.0-
E.运行时异常被抛出
第4题
A.4,3,7
B.3,4,7
C.5,2,7
D.2,5,7
第5题
A.Alloftheassertstatementsareusedappropriately.
B.Onlytheassertstatementonline31isusedappropriately.
C.Theassertstatementsonlines29and31areusedappropriately.
D.Theassertstatementsonlines26and29areusedappropriately.
E.Theassertstatementsonlines29and33areusedappropriately.
F.Theassertstatementsonlines29,31,and33areusedappropriately.
G.Theassertstatementsonlines26,29,and31areusedappropriately.
第6题
A.Movetheline12printstatementintothefoo()method.
B.Changeline7topublicsynchronizedvoidgo(){.
C.Changethevariabledeclarationonline3toprivatevolatileintx;.
D.Wrapthecodeinsidethefoo()methodwithasynchronized(this)block.
E.Wraptheforloopcodeinsidethego()methodwithasynchronizedblocksynchronized(this){//forloopcodehere}.
第7题
(1)定义枚举类型变量en,它包含两个枚举符front和back,请在注释“//**1**”之后添加适当的语句。
(2)在类Base中添加常成员虚函数void E()的定义,该函数输出“In Base E!”,请在注释“//**2**”之后添加适当的语句。
(3)在类A中添加常成员虚函数void E()的定义,该函数先调用基类中的虚函数 E()再输出“In AE!”,请在注释“//** 3**”之后添加适当的语句。
(4)完成类A构造函数的定义,请使用参数列表的形式初始化类A的成员,并输出“A constructor.”,请在注释“//** 4**”之后添加适当的语句。
输出结果如下:
Base constructor.
A constructor.
In BaseE!
In AE!
In BaseP!
In A!
1
A destructor.
Base destructor.
注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。
源程序文件test12_3.cpp清单如下:
include<iostream .h>
// ** 1 **
class Base
{
protected:
int b1;
int b2;
public:
Base();
~Base();
int Getb1()const { return b1; }
void Setb1(int x){ b1 = x; }
int Getb2()const { return b2; }
void Setb2(int y) { b2 = y; }
void Print()const {cout<<"In Base P!"<<end1;}
// ** 2 **
};
Base::Base():b1(1),b2(5)
{
cout<<"Base constructor."<<endl;
}
Base::~Base()
{
cout<<"Base destructor."<<endl;
}
class A:public Base
{
protected:
en enA;
public:
A();
~A();
en GetColor()const { return enA; }
void SetColor(en color){ enA = color; }
void InA(){cout<<"In A!"<<endl;}
// ** 3 **
{
Base::E();
cout<<"In AE!"<<endl;
}
};
// ** 4 **
{
cout<<"A constructor."<<endl;
}
A::~A()
{
cout<<"A destructor."<<endl;
}
void main()
{
A a1;
a1.E();
cout<<endl;
a1.Print();
a1.InA();
cout<<a1.Getbl()<<endl;
}
第8题
#include
int MaxValue(int x, int y)
{
return x>y? x:y;
}
int MinValue(int x,int y)
{
return x>y? y:x;
}
int main()
{
int a=4,b=3,c=5,d,e,f;
d=MaxValue(a,b);
d=MaxValue(d,c);
e=MinValue(a,b);
e=MinValue(e,c);
f=a+b+c-d-e;
printf("%d,%d,%d\n",d,f,e);
return 0;
}
A.5,4,3
B.3,5,4
C.3,4,5
D.5,3,4
第9题
A.编译失败
B.falsefalsetruetruetruetrue
C.truetruetruetruetruetrue
D.falsefalsetruetruetruefalse
E.truefalsetruefalsefalsetrue
F.运行时异常被抛出
第10题
A.23
B.21
C.22
D.编译错误
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!