上海神机软件有限公司Word格式.doc
《上海神机软件有限公司Word格式.doc》由会员分享,可在线阅读,更多相关《上海神机软件有限公司Word格式.doc(13页珍藏版)》请在冰点文库上搜索。
D.Outputisnull.
4:
source
fragement:
//point
x
Interesting{
//do
something
correctly
Java
syntax
at
point
x?
Givethefollowingjavasourcefragement:
//pointx
publicclassInteresting{
//dosomething
WhichstatementiscorrectlyJavasyntaxatpointx?
A.publicclassMyClass{//dootherthing…}
B.staticintPI=3.14
C.classMyClass{//dosomething…}
5:
What
will
be
result
of
executing
code?
boolean
a
=
true;
b
false;
c
if
(a
==
true)
(b
(c
true)
System.out.println("
Some
things
are
true
in
this
world"
);
else
Nothing
world!
"
&
c))
It'
s
too
confusing
to
tell
what
and
false"
Hey
won'
t
compile"
Choices:
Whatwillbetheresultofexecutingthefollowingcode?
booleana=true;
booleanb=false;
booleanc=true;
if(a==true)
if(b==true)
if(c==true)System.out.println("
Somethingsaretrueinthisworld"
elseSystem.out.println("
Nothingistrueinthisworld!
elseif(a&
(b=c))System.out.println("
stooconfusingtotellwhatistrueandwhatisfalse"
elseSystem.out.println("
Heythiswon'
tcompile"
A.Thecodewon'
tcompile
B."
willbeprinted
C."
D.Noneofthese
6:
//
Filename;
SuperclassX.java
package
packageX;
SuperclassX
{
protected
superclassMethodX()
superclassVarX;
}
Filename
SubclassY.java
1.package
packageX.packageY;
2.
3.public
SubclassY
extends
4.{
5.SuperclassX
objX
new
SubclassY();
6.SubclassY
objY
7.void
subclassMethodY()
8.{
9.objY.superclassMethodX();
10.int
i;
11.i
objY.superclassVarX;
12.}
13.}
//Filename;
SuperclassX.java
packagepackageX;
publicclassSuperclassX
{
protectedvoidsuperclassMethodX()
intsuperclassVarX;
}
//FilenameSubclassY.java
1.packagepackageX.packageY;
2.
3.publicclassSubclassYextendsSuperclassX
4.{
5.SuperclassXobjX=newSubclassY();
6.SubclassYobjY=newSubclassY();
7.voidsubclassMethodY()
8.{
10.inti;
11.i=objY.superclassVarX;
12.}
13.}
A.Compilationerroratline5
B.Compilationerroratline9
C.Runtimeexceptionatline11
7:
在下述选项时,没有构成死循环的程序是
A.inti=100while
(1){i=i%100+1;
if(i>
100)break;
}
B.for(;
;
C.intk=1000;
do{++k;
}while(k>
=10000);
D.ints=36;
while(s);
--s;
8:
WhichfragmentsarenotcorrectinJavasourcefile?
A.packagetestpackage;
publicclassTest{//dosomething...}
B.importjava.io.*;
packagetestpackage;
publicclassTest{//dosomething...}
C.importjava.io.*;
classPerson{//dosomething...}publicclassTest{//dosomething...}
D.importjava.io.*;
importjava.awt.*;
9:
下述程序代码中有语法错误的行是(
)。
i,ia[10],ib[10];
/*第一行*/
for
(i=0;
i<
=9;
i++)
/*第2行*/
ia[i]=0;
/*第3行*/
ib=ia;
/*第4行*/
下述程序代码中有语法错误的行是()。
inti,ia[10],ib[10];
/*第一行*/
for(i=0;
i++)/*第2行*/
ia[i]=0;
/*第3行*/
/*第4行*/
A.第1行
B.第2行
C.第3行
D.第4行
10:
在软件生命周期中,下列哪个说法是不准确的?
A.软件生命周期分为计划、开发和运行三个阶段
B.在计划阶段要进行问题焉醛和需求分析
C.在开发后期要进行编写代码和软件测试
D.在运行阶段主要是进行软件维护
11:
下面关于变量及其范围的陈述哪些是错的。
A.实例变量是类的成员变量。
B.实例变量用关键字static声明。
C.在方法中定义的局部变量在该方法被执行时创建
D.局部变量在使用前必须被初始化。
12:
Whichmodifiershouldbeappliedtoamethodforthelockofobjectthistobeobtainedpriortoexcutionanyofthemethodbody?
A.synchronized
B.abstract
C.final
D.static
13:
Considertheclasshierarchyshownbelow:
--------------------------------------------------------------------
classFourWheelerimplementsDrivingUtilities
classCarextendsFourWheeler
classTruckextendsFourWheeler
classBusextendsFourWheeler
classCraneextendsFourWheeler
----------------------------------------------------------------------
Considerthefollowingcodebelow:
1.DrivingUtilitiesdu;
2.FourWheelerfw;
3.TruckmyTruck=newTruck();
4.du=(DrivingUtilities)myTruck;
5.fw=newCrane();
6.fw=du;
Whichofthestatementsbelowaretrue?
A.Line4willnotcompilebecauseaninterfacecannotrefertoanobject.
B.Thecodewillcompileandrun.
C.Thecodewillnotcompilewithoutanexplicitcastatline6,becausegoingdownthehierarchywithoutcastingisnotallowed.
D.Thecodewillcompileifweputanexplicitcastatline6butwillthrowanexceptionatruntime.
14:
以下的C程序代码片段运行后C和d的值分别是多少
Inta=1,b=2;
Intc,d;
c=(a&
b)&
a;
d=(a&
A.0,0
B.0,1
C.1,0
D.1,1
15:
printed
when
you
execute
X
Y
Y();
X()
{
System.out.print("
X"
Y()
Y"
Z
y
Z()
Z"
main(String[]
args)
Z();
Whatwillbeprintedwhenyouexecutethefollowingcode?
classX
Yb=newY();
X()
{
System.out.print("
}
classY
Y()
{
System.out.print("
}
publicclassZextendsX
Yy=newY();
Z()
System.out.print("
}
publicstaticvoidmain(String[]args)
{
newZ();
A.Z
B.YZ
C.XYZ
D.YXYZ
16:
code:
args[]
){
l=0;
do{
System.out.println(“Doing
it
l
is:
”+l);
}while(--l>
0)
System.out.println(“Finish”);
well
output:
Givethefollowingcode:
publicstaticvoidmain(Stringargs[]){
intl=0;
do{
System.out.println(“Doingitforlis:
0)
Whichwellbeoutput:
A.Doingitforlis3
B.Doingitforlis1
C.Doingitforlis2
D.Doingitforlis0
17:
The
code
entire
contents
file
called
Example.java,causes
precisely
one
error
during
compilation:
SubClass
BaseClass{
BaseClass(){
String
str;
System.out.println(“ok”);
BaseClass(String
s){
str=s;
}}
method(){
s=new
SubClass(“hello”);
BaseClass
b=new
BaseClass(“world”);
line
would
cause
error?
ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation:
classSubClassextendsBaseClass{
}
classBaseClass(){
Stringstr;
publicBaseClass(){
System.out.println(“ok”);
publicBaseClass(Strings){
str=s;
}}
publicclassExample{
publicvoidmethod(){
SubClasss=newSubClass(“hello”);
BaseClassb=newBaseClass(“world”);
Whichlinewouldbecausetheerror?
A.9
B.10
C.11
D.12
18:
设有变量说明语句inta=1,b=0;
则执行以下程序段的输出结果为()。
switch(a)
{
case1:
switch(b)
case0:
printf("
**0**"
break;
**1**"
case2:
**2**"
\n"
A.**0**
B.**0****2**
C.**0****1****2**
D.有语法错误
19:
Whatiswrittentothestandardoutputgiventhefollowingstatement:
System.out.println(4|7);
Selecttherightanswer:
A.4
B.5
C.6
D.7
20:
Whichisthemain()methodreturnofaapplication?
A.String
B.byte
C.char
D.void
21:
Math.round(11.5)等於多少?
A.11
B.12
C.11.5
简答题
22:
说出ArrayList,Vector,LinkedList的存储性能和特性。
23:
找出32位数中是回文数,且其开方为整数的数。
24:
X博士是一个研究儿童智力开发方法的科学家,他为幼儿教育领域做出了许多贡献。
最近,X博士正在研究一种适合儿童的游戏,用以辅助发展儿童的观察力、注意力和思维能力。
经过连日的构思,X博士终于设计出了一种游戏:
彩球游戏。
彩球游戏是一种单人参与的游戏,游戏首先给出一串由许多不同颜色的小球组成的小球序列,以及一个整数参数M(M≥2)。
一段连续的具有相同颜色的小球序列称为连续同色序列。
小孩,即游戏参与者,每次可以向任意一段连续同色序列插入一个同色小球,使该序列的长度加一。
当一段连续同色序列在插入一个同色小球后其长度达到M时,该序列就会爆炸消失,然后原序列两边的其余小球会重新连成一串,如果两段相同颜色的连续同色序列在此时连接在一起,它们就会合并形成一段新的连续同色序列。
如果新形成的连续同色序列长度达到M,这段序列也会爆炸消失,然后重复上述过程,直到没有新的长度达到M的连续同色序列出现为止。
游戏的目标很简单,就是插入尽量少的小球,使得所有小球都爆炸消失掉。
通过长时间的游戏和不断提高游戏水平,这个游戏可以很好地开发儿童的观察力、注意力和思维能力。
但是X博士仍然面临着一个困难的问题,他还需要设计出一个游戏演示AI程序,可以以最优的方式(即插入的小球数量最小)进行游戏,用于游戏教学,或