适用专业:
分,
1、以下关于方法描述正确的是()
A.方法必须定义在类中
B.方法如果没有返回值,要使用NULL作为返回类型
C.方法中必须要有return关键字
D.方法不能在类外部被调用
2、下面代码片段创建()个对象。
int a = 10;
String b = "abc";
String c = new String("abc");
MyTest test = new MyTest();
A. 1
B.2
C.    3
D.4
3、假设val是整型变量,下面()说法不正确。
if(val > 4){
System.out.println("Test A");
}else if(val > 9){
System.out.println("Test B");
}else {
System.out.println("Test C");
}
A.val = 0输出“Test C”
B.val介于0到4 之间输出“Test C”
C.val = 14输出“Test B”
D.val = 5 输出“Test A”
4、有下面程序,语句a=a+1执行的次数是()
public class Test {
public static void main(String[ ] args){
int x=8,a=1;
do{
a=a+1;
} while (x>0);
}
}
A.0
B.1
C.无限次
D.有限次
5、声明s1,
String s1 = new String("phenobarbital");
经过下面代码之后,
String s2 = s1.substring(3, 5);
s2的值是()。
A.null
B."eno"
C."enoba"
D."no"
6、下列()中main方法可以作为应用程序入口。
A.public void main(String[ ] args){ //程序主体}
B.public static void main(){ //程序主体}
C.public static void main(String[ ] a){ //程序主体}
D.public static void main(String args){ //程序主体}
7、以下循环体的执行次数是()。
int i, j;
for (i=0, j=1; i<=j+1; j--) {
i = i + 2;
}
A. 3
B.2
C.    1
D. 0
8、关于下面代码片段,说法正确的是()。
int a = 8, b = 9;
if (a = b){
System.out.println("true");
}else{
System.out.println("false");
}
A.输出true    D.输入false    C.无输出  D.编译错误
9、下面程序中,while循环的循环次数是()。
public static void main(String[ ] args){
int i = 0;
while(i<10){
if(i<1){
continue;
}
if(i==5) {
break;
}
i++;
java语言使用的字符码集是}
}
A.1
B. 10
C. 6
D. 死循环
10、关于下面代码,说法正确的是()。
public class Test {
public static void main(String[ ] args1){
Test test = new Test();
int x = 10;
if (hodA()){
x++;
System.out.println(x);
}
}
public int methodA(){
return 10;
}
}
A.第5行有编译错误
B.第7行有编译错误
C.第11行有编译错误
D.运行输出11
11、要求以下程序的功能是计算:
s=1+1/2+1/3+…+1/10=2.9289682…
public class MyTest {
public static void main(String args[ ]){
int n;
double s;
s=1.0;
for(n=10;n>1;n--){
s=s+1/n;
}
System.out.println(s);
}
}
程序运行后,输出结果错误,导致程序出错的是()。
A.s = 1.0
B. for(n=10;n>1;n--)
C. s = s + 1 /n
D. System.out.println(s);
12、在一个Java文件中,使用import、class和package的正确顺序是()。
A.package、import、class
B.class、import、package
C.import、package、class
D.package、class、import
13、下面()不是String对象合法的方法。
A.equals(String)
B. trim()
C. append()
D. indexOf()
14、运行下面代码,正确的输出结果是()。
public class MyClass {
static int x = 10;
public static void main(String args[ ]){
for(int n = 3; n > 0; n--){
x = x * x;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。