您的位置:首页 > 其它

下面的方法,当输入为2的时候返回值是多少?

2016-04-21 18:46 393 查看
27. 下面的方法,当输入为2的时候返回值是多少?()

public static int getValue(int i) {
int result = 0;
switch (i) {
case 1:
result = result + i;
case 2:
result = result + i * 2;
case 3:
result = result + i * 3;
}
return result;
}


A0                    B2                    C4                     D10

答案:D

解析:注意这里case后面没有加break,所以从case 2开始一直往下运行
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: