更多"[单选题]给出如下代码片段,运行结果为( ): String a = "的相关试题:
[单选题]给出如下代码片段,运行结果为( ): String a = “ABCD”; String b = a.toLowerCase(); b.replace(‘a’, ‘d’); b.replace(‘b’, ‘c’); System.out.println(b);
A.abcd
B.ABCD
C.dccd
D.dcba
[单选题]给出如下代码:
class Test{
private int m;
public static void fun() {
// some code...
}
}
如何使成员变量m 被函数fun()直接访问()
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
[单选题]分析下列代码片段的执行结果()
int count = 5;
while (count > 1)
{
--count;
Console.Write(count);
}
A.4332
B.4321
C.4521
D.4322
[单选题]分析下列代码片段的执行结果是()
if (true) {
Console.Write("Hello");
Console.Write("World");
}
A.无输出
B.HelloWorld
C.Hello
D.Hello World
[单选题]预测以下代码片段的输出结果()var str ;
alert(typeof str);
A.string
B.undefined
C.object
D.String
[单选题]分析下列代码片段的执行结果()
int score = 80;
if (score > 90) {
Console.WriteLine("好");
} else if (score > 80) {
Console.WriteLine("良好");
} else {
Console.WriteLine("一般");
}
A.好
B.良好
C.一般
D.80
[单选题]分析下列代码片段的执行结果()
bool boo = true;
if (boo == false) {
Console.WriteLine("a");
}else{
Console.WriteLine("b");
}
A.输出b
B. 输出a
C. 输出c
D. 运行时出错
[单选题]分析下列代码片段的执行结果()
int a = 10, b = 10;
string c=”10”;
Console.WriteLine(a+b+c);
A.2010
B.30
C.101010
D.编译报错,提示数据类型不匹配
[单选题]分析下列代码片段的执行结果()
int num1 = 22; int num2 = 7;
if (num1 > num2) {
Console.WriteLine("num1大");
Console.WriteLine("num1={0}", num1);
} else {
Console.WriteLine("num2大");
Console.WriteLine("num2={0}", num2);
}
A.num1大;num1=22
B. num2大;num2=7
C.num1大num1=22
num2大num2=7
D. 语法错误不能运行
[单选题]分析下列代码片段的执行结果()
int x=5,y=10;
Console.WriteLine("{0}+{1}={2}",y,x,y+x);
A.y+x=15
B.x+y=15
C.5+10=15
D.10+5=15
[单选题]当month等于9时,分析下列代码片段的执行结果()
int days = 0;
switch (month)
{
case 2:
days = 28;
break;
case 4:
case 6:
case 9:
case 11:
days = 30;
break;
default:
days = 31;
break;
}
Console.WriteLine(days);
A.0
B.30
C.29
D.31
[单选题]分析下列代码片段的执行结果()
int a = 10; string b = "10";
Console.WriteLine(a+b);
A.20
B.1010
C.10+10
D.语法错误
[单选题]分析下列代码片段的执行结果()
int x = 8;
int y = x++;
Console.WriteLine(y);
y = ++x;
Console.WriteLine(y);
A.8 9
B.9 9
C.9 10
D. 8 10
[单选题]给定如下Java代码,编译运行的结果是()
public class Test {
public static void main(String[] args) {
LinkedList list=new LinkedList();
list.add("A");
list.add(2,"B");
String s=(String)list.get(1);
System.out.println(s);
}
}
A.编译时发生错误
B.运行时引发异常
C.正确运行,输出:A
D.正确运行,输出:B
[单选题]分析下列代码片段的执行结果是()
int a = 21, b = 22, c = 23;
if (a < b)
{
Console.WriteLine(b);
} else {
Console.WriteLine(a + b + c);
}
A.21
B.22
C.23
D.66
[单选题]分析下列代码片段的执行结果是()
int a = 15, b = 21, m = 0;
switch (a % 3)
{
case 0: m++; break;
case 1: m++;
switch (b % 2)
{
case 0: m++; break;
default: m++; break;
}break;}Console.WriteLine("{0}",m);
A.1
B.2
C.3
D.4
[单选题]分析下列代码片段的执行结果()
int x = 2, y = -1, z = 2;
if (x < y){
if (y < 0) {
z = 0
};
}else{ z += 1;}
Console.WriteLine("{0}",z);
A.3
B.2
C.1
D.0
[单选题]分析下列代码片段的执行结果()
int x, y = 1, z = 0;
if (z < 0) {
x = 3;
} else if (y == 0) {
x = 5;
}else{
x = 7;
}
Console.WriteLine(x + "," + y);
A. 7, 1
B.7, 1
C.3, 3
D.以上都不正确
[单选题]分析下列代码片段的执行结果()
int y = 1, x;
if (y != 0) {
x = 5;
}else if (y < 0) {
x = 4;
}else{
x = 3;
}
Console.WriteLine("x={0}", x);
A.4
B.3
C.5
D.以上都不对