文档详情

(Java习题二.doc

发布:2017-01-18约8.3千字共10页下载文档
文本预览下载声明
指出下列程序的运行结果 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.print(ex.str+ and );     Sytem.out.print(ex.ch);   }   public void change(String str, char ch[]) {     str=test ok;     ch[0]=g;   } } 传值和传地址 ① good and abc ② good and gbc ③ test ok and abc ④ test ok and gbc 2. 给出下面代码: public class Person {   static int arr[] = new int[10];   public static void main(String a[])   {    System.out.println(arr[1]);   } } 哪个语句是正确的? ① 编译时将产生错误; 编译时正确,运行时将产生错误; 输出零; 输出空。下列哪些语句关于内存回收的说明是正确的? 程序员必须创建一个线程来释放内存; 内存回收程序负责释放无用内存 内存回收程序允许程序员直接释放内存 内存回收程序可以在指定的时间释放内存对象 1) public void modify() { 2) int I, j, k; 3) I = 100; 4) while ( I 0 ) { 5) j = I * 2; 6) System.out.println ( The value of j is + j ); 7) k = k + 1; 8) I--; 9) } 10) } ① line 4 ② line 6 ③ line 7 局部变量必须初始化,成员变量不需初始化,数组不需初始化 ④ line 8 5.指出下列哪方法与方法public void add(int a){}为合理的重载方法。 public int add(int a) ② public void add(long a) ③ public void add(int a,int b) ④ public void add(float a) 6.给出下面代码段 1) public class Test {   2) int m, n;   3) public Test() {}   4) public Test(int a) { m=a; }   5) public static void main(String arg[]) {   6) Test t1,t2;   7) int j,k; 8) j=0; k=0;   9) t1=new Test();   10) t2=new Test(j,k);   11) }   12) }   哪行将引起一个编译时错误? ine 3 line 5 line 6 line 10 7.main()方法的返回类型是: int ② void ③ Boolean ④ static 8.System类在哪个包中? java.utiljava.io java.awt java.lang 9.给出下面代码: public class est {     static int a[] = new a[10]; public static void main(String args[]) {      System.out.println(a[10]);     }   } 那个选项是正确的? ① 译时将产生错误;编译时正确,运行时将产生错误;输出零;输出空。String s = hello;   String t = hello;   char c[] = {h,e,l,l,o} ; 下列哪些表达式返回true? s.equals(t);t.equals(c);f s==t;t t.equals(new String(hello));t 11.下述哪些说法是正确的? 实例变量是类的成员变量 实例变量是用static关键字声明的方法变量在方法执行时创建方法变量在使用之前必须初始化public class Something { ?? voi
显示全部
相似文档