请勿在纸上答题及写任何字体!
一. 选择题(每题3分)
1、(重载定义,答案:A,C)
给出如下代码:
public class MethodOver {
public void tVar (int a, int b, float c) {
}
}
哪两个是tVar的重载函数?AC
A. Private void tVar (int a, float c, int b) { }
B. Protected void tVar (int a, int b, float c) { }
C. Public int tVar (int a, float c, int b) (return a;)女士假发图片
D. Public int tVar (int a, int b, float c) (return a;)
E. Protected float tVar (int a, int b, float c) (return c;)
2、(++,――运算符;答案:D)
给出如下代码:A
int i =1,,j =10;
do {
if(i++> --j) {
continue;
}
} while (i <5);
System.out.println(“i = “ +i+ “and j = “+j);
程序运行结果是什么?
A. i = 6 and j = 5 B. i = 5 and j = 5 C. i = 6 and j = 5
D. i = 5 and j = 6 E. i = 6 and j = 6
3、(线程的停止;答案:AC)
哪两个不能直接停止线程的执行?CE
A. Existing from a synchronized block.
B. Calling the wait method on an object.
C. Calling notify method on an object.
D. Calling read method on an InputStream object.
E. Calling the SetPriority method on a Thread object.
4、( static关键字的使用; 答案:C)
给出如下代码:
class Test{
private int m;
public static void fun() {
// some&
}
}
如何使成员变量m被函数fun()直接访问?C
A、将private int m改为protected int m B、将private int m改为public int m
C、将private int m 改为static int m D、将private int m改为int m
5、(赋值语句,this的用法; 答案: C,D)
给出下面的代码段:
public class Ba{
int w, x, y ,z;
public Ba(int a,int b)
{
x=a; y=b;
}
public Ba(int a, int b, int c, int d)
{
// assignment x=a, y=b
w=d;
z=c;
}
}
在代码说明// assignment x=a, y=b处写入如下哪几个代码是正确的?BC
A、 Ba(a,b); B、x=a, y=b; C、x=a; y=b; D、this(a,b);
6、(STRING类型数据的赋值语句;答案:A,D)
已知如下定义:String s = "story";
下面哪个表达式是合法的?AD
A、s+="books"; B、char c=s[1]; C、int len=s.length; D、String LowerCa();
7、(main()函数返回值类型;答案:D)
Java中main()函数的返回值是什么类型?D
A、 String B、int C、char D、void
8、(JAVA标识符; 答案:A,E)
如下哪些字串是Java中的标识符?AE
A、 fieldname B、super C、3number D、#number E、$number
9、(main()函数的参数; 答案:C)
下面哪个是main()函数的合法参数?C
A、char args[] B、char args[][] C、String arg [] D、String args
10、(线程的执行; 答案:C)
以下哪个方法用于定义线程的执行体?C
A、 start() B、init() C、run() D、main() E、synchronized()
铁山寺国家森林公园11、(成员常量的定义; 答案:B结婚50年)
以下哪个约束符可用于定义成员常量?AB
A、 static B、final C、abstract D、No modifier can be ud
12、(new的用法; 答案:E)
给出如下代码:
1: class Example{
2: String str;
3: public Example(){
4: str= "example";
5: }
6: public Example(String s){
7: str=s;
8: }
9: } }
10: class Demo extends Example{
11: }
12: public class Test{
13: public void f () {
14: Example ex = new Example("Good");
15: Demo d = new Demo("Good");
16: } }
哪句语句会导致错误?E
A、 line 3 B、line 6 C、line 10 D、line 14 E、line 15
13、(类的定义; 答案:B,D)
在如下源代码文件Test.java中, 哪个是正确的类定义?BD
A、 public class test {
public int x = 0;
public test(int x)
{
this.x = x;
}
}
B、public class Test{
public int x=0;
public Test(int x) {
this.x = x;
}
}
C、public class Test extends T1, T2 {
public int x = 0;
public Test (int x) {
this.x = x;
落得打
}
碰碰车游戏}
D、 public class Test extends T1{
public int x=0;
public Test(int x){
this.x = x;
}
}
E、protected class Test extends T2{
public int x=0;
public Test(int x){
this.x=x;
}
}
14、 (if el if的用法(太简单); 答案:D)
给出下面的代码:
if (x>0) { System.out.println("first"); }
el if (x>-3) { System.out.println("cond"); }
el { System.out.println("third"); }
x的取值在什么范围内时将打印字符串"cond" D
A. x > 0 B. x > -3 C. x <= -3 D. x <= 0 & x > -3
15平板电脑的系统、(数组下标,lenth()的用法; 答案:B)
已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 };
下面哪个表达式的值与数组下标量总数相等?D
A、 m.length() B、m.length C、m.length()+1 D、m.length+1
16、(数组; 答案:B)
已知如下代码:
public class Test
{
long a[] = new long[10];
public static void main ( String arg[] ) {
蛋炒饭什么意思System.out.println ( a[6] );
}
}
请问下列哪个描述是正确的? C
A、Output is null. B、Output is 0.
C、When compile, some error will occur. D、When running, some error will occur.
17、(native方法的定义; 答案:A)
如下哪个语句正确说明了native方法?B
A、public native void test(); B、public native void test(){}
C、public void native test(); D、public native test(){}
18、(EJB; 答案: D)
What is a benefit of bean pooling in an EJB container?
A. It improves the portability between databas.
B. It reduces the number of databa connections.
C. It provides better support to object-oriented databas.
D. It reduces the memory allocation and garbage-collection cycles.
19、(继承的概念; 答案A,D)
下面关于继承的哪些叙述是正确的?AD
A. 在java中只允许单一继承。
B. 在java中一个类只能实现一个接口。
C. 在java中一个类不能同时继承一个类和实现一个接口。
D. java的单一继承使代码更可靠。
20、妹妹简笔画(垃圾收集的概念; 答案:B)
关于垃圾收集的哪些叙述是正确的?BD
A. 程序开发者必须自己创建一个线程进行内存释放的工作。