西安交通大学18年3月课程考试《Java语言》作业考核试题
共题,总分:100分
一、单选题共25题,50分
1、2分下面的表达式哪个是正确的(A )
AString s="你好";int i=3; s+=i;
BString s="你好";int i=3; if(i==s){ s+=i};
CString s="你好";int i=3; s=i+s;
DString s="你好";int i=3; s=i+;
2、2分对方法main的第1行定义正确的是(D)。。
Apublic main( String arg [ ] )
Bpublic void main( String arg [ ] )
Cpublic static void main( String arg [ ] )
Dpublic static void main( String args [ ] )
3、2分下面不是合法标识符的是(A)
A2ofUS
BgiveMes
CwhataQuiz
D$d2000_
4、2分运行下列程序,会产生什么结果(B)class Outer1{ private int a;void foo(double d,final float f){ String s; final boolean b; classInner{ void methodInner(){ System.out.println("in the Inner"); }} } public static void main(String args[]) { Outer1me=new Outer1(); me.foo(123,123); System.out.println("outer");
} } 。。
Ain the Inner outer
Bouter
Cin the Inner
D编译不通过
5、2分对于下列代码:1) class Person { 2) public void printValue(int
i, int j) {... } 3) public void printValue(int i){... } 4) }
5) public class Teacher extends Person { 6) public void
printValue() {... } 7) public void printValue(int i) {...}
8) public static void main(String args[]){ 9) Person t = new
Teacher(); 10) t.printValue(10); 11) } 第10行语句将调用哪行
语句?(D)。。