基础笔试题一

1.(单选题)序列[15, 67, 26, 43, 61, 25, 84, 80, 34, 70]进行冒泡排序时,第三趟排序的结果是:(b)。
A.[15, 26, 43, 61, 25, 67, 80, 34, 70, 84]
B.[15, 26, 25, 43, 61, 34, 67, 70, 80, 84]
C.[15, 26, 43, 25, 61, 67, 34, 70, 80, 84]
D.[15, 25, 26, 43, 34, 61, 67, 70, 80, 84]

(单选题)请看下列代码:
public int list(String id){
return 0;
}
list方法的使用正确的是:(c)。
A.int count=list(1002);
B.String count=list(1002);
C.int count=list(“s1001”);
D.String count=list(“s1001”);

3.(单选题)请看下列代码:
public static void main(String[] args) {

int[]  list ={10,55,78,34,23,5,67};

for(int i=0;i<《插入代码1》;i++){

 System.out.println(《插入代码2》);

}

}
如果上述代码的作用为遍历数组中的每一个元素,将其输出到控制台,那么《插入代码1》处和《插入代码2》处,
应填入的代码分别为:(d)。
A.list.size和list
B.list.size和list[i]
C.list.length和list
D.list.length和list[i]

4.(单选题)下列代码段编译和运行的结果是:(b)。
public static void main(String[] args) {
int result=0;
for (int i=0; i <= 10; i++) {
if (i > 5){
break;
}
result+=i;
}
System.out.println(result);
}
A.输出50
B.输出15
C.输出10
D.编译错误

5.(单选题)下列程序编译或运行的结果是:(d)。
public static void main(String args[]) {
int width = 50;
int height;
int result;
if (width > 40) {
right = 9;
}
result = width + height;
System.out.println(result);
}
A.输出:10
B.输出:19
C.输出:9
D.编译出错

6.(单选题)下列语句的输出结果是:(a)。
System.out.println(5+7+“tarena”+5+7);
A.12tarena57
B.57tarena12
C.57tarena57
D.12tarena12

7.(单选题)下面代码的输出结果是:(b)。
public static void main(String[] args) {
int s1 = 50;
int s2 = 30;
s1 = s1 + s2;
s2 = s1 - s2;
s1 = s1 - s2;
System.out.println(s1 + “,” + s2);
}
A.50,30
B.30,50
C.50,80
D.80,30

8.(单选题)请看下列代码的输出结果是:(c)。
public static void main(String[] args) {
double opr = 0;
int compare = opr > 0 ? 1 : (opr < 0 ? -1 : 0);
System.out.println(“f(” + opr + “)=” + compare);
}
A.f(0.0)=1
B.f(0.0)=-1
C.f(0.0)=0
D.f(0.0)=-2

9.(单选题)以下程序的输出结果为:(a)
public static void main(String args[]) {
int a=10;
int b=20;
boolean flag=a++>b–&&b++>a–;
System.out.println(flag+",a="+a+",b="+b);
}
A.false,a=11,b=19
B.false,a=10,b=20
C.true,a=11,b=19
D.true,a=10,b=20

10.(单选题)请看下列代码:
public void testType() {
if (isType(1)) {
System.out.println(“Type”);
} else {
System.out.println(“Not type”);
}
}
public boolean isType(int type) {
if (type == 1) {
return false;
}
return true;
}
调用testType方法,程序编译和运行的结果是:(b)。
A.输出:Type
B.输出:Not Type
C.代码 if (isType(1)) { 行,编译错误
D.代码 return true; 行,编译错误

11.(单选题)请看下列代码编译和运行的结果是:(d)。
public static void main(String[] args) {
int pigs = 5;
boolean isOne = true;
boolean isTwo = false;
if ((pigs == 4) && !isTwo)
System.out.print(“first”);
System.out.print("second ");
if ((isTwo = true) && isOne) {
System.out.print(“third”);
}
}
A.编译错误
B.输出:third
C.输出:first second
D.输出:second third

12.(单选题)下列代码段中,循环执行的次数是:(c)。
public static void main(String[] args) {
int words = 27;
do {
words–;
} while (words <= 18);
}
A.9次
B.0次
C.1次
D.超过9次

13.(单选题)下列代码的输出结果是:(c)。
public static void main(String[] args) {
int i = 24, j = 32, h = 58;
switch (j - i) {
case 7:
h++;
case 8:
h++;
case 9:
h += 2;
case 10:
h += 3;
default:
h /= j;
}
System.out.println(h);
}
A.59
B.61
C.2
D.1

14.(单选题)下列代码的输出结果是:(c)。
public static void main(String[] args) {
int one = 1, two = 10, three = 8;
if (one > 2) {
if (two < 5) {
System.out.println(“one”);
} else {
System.out.println(“two”);
}
} else if (three > 5) {
System.out.println(“three”);
} else {
System.out.println(“four”);
}
}
A.one
B.two
C.three
D.four

15.(单选题)下面程序的输出结果是:(a)。
public static void main(String[] args) {
int s = 105;
int result = 0;
while (s > 0) {
int m = s % 10;
result += m;
s /= 10;
}
System.out.println(result);
}
A.6
B.10
C.5
D.20

16.(多选题)关于下列代码说法正确的是:(cd)。
public static void main(String[] args) {
int words = 40;
System.out.println(words);
System.out.println(computers);
words = 67.9;
}
A.编译正确
B.代码System.out.println(words);行,编译出错
C.代码System.out.println(computers);行,编译出错
D.代码words = 67.9;行,编译出错

17.(多选题)请看下列表达式正确的是:(ab)。
A.String ename = “Allen”;
B.int $words=40;
C.float _top =23.9;
D.double ~balance = 99.9;

18.(多选题)下列数组定义及赋值,正确的是:(ac)。
A.byte[] arr = new byte [15];
B.byte arr = new byte [20];
C.byte arr[]={1,2,3,4,5};
D.byte[10] arr= new byte[];

19.(多选题)请看下列代码:
public static void main(String[] args) {
《插入代码》
if (isRight) {
System.out.println(“right!”);
}
}
请在《插入代码》处,填入变量isRight声明的同时,进行初始化的代码:(ad)。
A.boolean isRight=false;
B.int isRight=1;
C.int isRight=0;
D.boolean isRight = true;

20.(多选题)下列选项的数据类型中,能存储汉字“达”的是:(ad)。
A.int
B.byte
C.short
D.char

原创文章 34 获赞 20 访问量 1110

猜你喜欢

转载自blog.csdn.net/qq_22744093/article/details/105741837
今日推荐