1. 已知如下代码:
public class Test {
long a[] = new long[10];
public static void main(String[] args) {
System.out.println(a[6]);
}
}
请问哪个语句是正确的(A)
A. When running,some error will occur.
B. When compile,some error will occur.
C. Output is null.
D. Output is 0.
2. 哪种定义数组是正确的?(C)
A. Object[] objarr = new String[];
B. String[] objarr2 = new String[2]{“str1”,“str2”};
C. Object[] objarr3 = new String[]{“str1”,“str2”};
D. String[] objarr4 = new Object[]{“str1”,“str2”};
3. 这段代码的输出是什么?(D)
public class Test {
public static void main(String[] args) {
int num = 1;
System.out.println("changeNum()方法调用之前:num = " + num);
changeNum(num);
System.out.println("changeNum()方法调用之后:num = " + num);
}
public static void changeNum(int x){
x = 2;
}
}
A. 1,2
B. 1,3
C. 2,2
D. 1,1
4. Which of the following statements are true?(C,D)
A. The == operator determines if the contents and type of two separate objects match.
B. The equals() method determines if reference values refer to the same object.
C. The equals() method returns true only when the contents of two objects match.
D. The class File overrides equals() to return true if the contents and type of two separate objects match.
5. 哪些返回true
String s = "hello",
String t = "hello",
char c[] = {'h','e','l','l','o'};
Which retrun true?(A,B,C)
A. s.equals(t);
B. t.equals(new String(“hello”);
C. s == t;
D. t.equals( c );
E. t == c.
6.var a;
var b = ‘’;
var c = ‘test’;
var d = a||b||c;
此时d的值是多少?(D)
A. true
B. undefined
C. false
D. ‘test’
E. ‘’
F. null
7. let x = 'fahk.jfdsfj.hf,hd,fhdshsd’字符串中的逗号替换为|符号,哪种操作正确(B)
A. x.replace(’,’,’|’)
B. x.replcae(/,/g,’|’)
C. x.replace(’,’,’!’)
D. x.replace(’|’,’,’)
8. let x = [],x.push(‘1’),x.push(‘2’),x.push(‘3’),说法正确的是(A)
A. 执行x.toString()一定不会报错
B. x.replice(x[0],‘0’),x中的数值会变
C. x.splice(3,1)后,x中的数量会变少
D. 数值类型不同,编译会报错
9. 以下说法正确的是(A,C,D)
A. js中,数组可以通过一次for循环删除数组自身的多个元素
B. java中父类的对象一定访问不了子类的方法或者变量
C. Spring中我们也可以通过@Bean注解开启对象的单例
D. java中使用for循环遍历list集合的同时删除元素,集合元素会减少
10. 以下代码写法运行正确的是(A,B,C,D)
A. let x=’’;
B. const x=undefined;
C. String a = null;
D. var x=’’;