2025年11月21日
未分类
2025年11月21日
class Person { private int a; public int change(int m){ return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]){ Person p = new Person(); Teacher t = new Teacher(); int i; // point x } } 在 // point x安排哪个语句合法? A.i = b; B.i = m; C.i = p.a; D. i = p.change(30);
class Person { p...
2025年11月21日
设有如下代码段 1 String s = null; 2 if ( s != null & s.length() > 0) 3 System.out.println(“s != null & s.length() > 0”); 4 if ( s != null && s.length() > 0) 5 System.out.println(“s != null & s.length() > 0”); 6 if ( s != null || s.length() > 0) 7 System.out.println(“s != null & s.length() > 0”); 8 if ( s != null | s.length() > 0) 9 System.out.println(“s != null | s.length() > 0”); 哪些行将抛出空指针异常? 假设在检查过程中把抛出异常的if语句注释掉继续验证. A.2,4 B.2,4,6,8 C.2,6,8 D.6,8
设有如下代码段 1 String...
2025年11月21日
2025年11月21日
有如下代码: public class Test{ public static void main(String args[]) { String str = new String(“World”); char ch[] = {‘H’,’e’,’l’,’l’,’o’}; change(str,ch); System.out.println(str + “and” + ch); } public static void change(String str, char ch[]) { str = “Changed”; ch[0] = ‘C’; } } 运行后输出的结果是: A.World and CelloChanged and Hello B.World and Cello C.World and Hello D.Changed and Cello
有如下代码: public cl...