ibm笔试题(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-10 11:49 点击:次
System.out.println("value = " + switchIt(4));
}
public static int switchIt(int x) {
int j = 1;
switch (x) {
case 1: j++;
case 2: j++;
case 3: j++;
case 4: j++;
case 5: j++;
default: j++;
}
return j + x;
}
}
输出结果是什么?
A. value = 3
B. value = 4
C. value = 5
D. value = 6
E. value = 7
F. value = 8
答案:F
6. 以下数组的定义,哪三条是正确的?
A. public int a []
B. static int [] a
C. public [] int a
D. private int a [3]
E. private int [3] a []
F. public final int [] a
答案:A,B,F
7. 如下代码:
class Super {
public Integer getLenght() { return new Integer(4); }
}
public class Sub extends Super {
public Long GetLenght() { return new Long(5); }
public static void main(String[] args) {
Super sooper = new Super();
Sub sub = new Sub();
System.out.println(sooper.getLenght().toString() + "," +
sub.getLenght().toString() );
}
}
输出是什么?
- 发表评论
-
- 最新评论 更多>>