一.单选

1.下面那一项是正确的?
A.ArrayList myList = new Object();
B.List myList = new ArrayList();
C.ArrayList myList = new List();
D.List myList = new List();

2.根据下面的代码,
如果String s = null;会抛出NullPointerException异常的有
① If((s!=null) &(s.length()>0))...
② If((s!=null) && (s.length()>0))...
③ If((s==null) | (s.length()==0))...
④ If((s==null) || (s.length() == 0))..
A 1和2 B .2和4 C.1和3 D.3和4

3.指出下列程序运行的结果是
public class Example{
String str = new String("good");
char[] ch = {'a','b','c'};
public static void main(String[] args) {
Example ex = new Example();
ex.change(ex.str,ex.ch);
System.out.println(ex.str + " and ");
System.out.println(ex.ch);
}
public void change(String str,char ch[]) {
str = "test ok";
ch[0] = 'g';
}
}

A good and abc B good and gbc
C test ok and abc D test ok and gbc

内容:B. good and gbc

Java 面试题:单选题及解析

原文地址: https://www.cveoy.top/t/topic/pxB6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录