ImageVerifierCode 换一换
格式:DOCX , 页数:39 ,大小:26.42KB ,
资源ID:5423474      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5423474.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(第4章 数组字符串向量和哈希表.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

第4章 数组字符串向量和哈希表.docx

1、第4章 数组字符串向量和哈希表 第四章 数组、字符串、向量和哈希表4.1 判断正误*对于数组int t=1,2,3),4,5,6来说,t .length等于3,t0 .length等于2。4.2 填空题*数组对象的长度在数组对象创建之后,就不能改变。数组元素的下标总是从0开始的。4.3 填空题*已知数组a的定义是“int a =1,2,3,4,5;”,则这时a2= 3。已知数组b的定义是“int b一new int5;”,则这时b2=0。已知数组c的定义是“Object c=new Object5;”,则这时c2=null。4.4 填空题*下面程序的输出是12。 class J_Test pu

2、blic static void main(String args) Strings=”1”,”2”); mb_swap( s0,s1); System. out. print(s0+sl); /方法main结束 static void mb_swap(String s0,String sl) String t=s0; s0=sl; sl=t; /方法mb_swap结束 /类J_Test结束4.5 填空题*在Java语言中,字符串直接量是用双引号()括起来的字符序列。字符串不是字符数组,而是类java.lang.String的实例对象4.6 填空题*运行下面程序,将输出331212。 publ

3、ic static void main(String args ) System. out. print(l+2); System. out. print(l+2+”); System. out. print(l+2); System. out. println(+1+2); /方法main结束 /类J_Test结束4.7填空题*下面的程序片段被执行后,s2的值是12345678,s3的值是12345678,b的值是false。 String sl=1234; String s2=sl. concat(5678); String s3=sl+5678; boolean b=(s2=s3);4.

4、8填空题*下面程序运行的结果是123412345678null。 public class J_Test public static String m_s; public static void main(String args ) String sl=1234; String s2=sl; s2+=5678: sl.concat(5678); System. out. println( sl+s2+m_s); /方法main结柬 /类J Test结束 4.9填空题*下面程序运行的结果是14。 public class J_Test public static String m_s; publ

5、ic static void main(String args ) String s0=” ”;/s0是只含有1个空格的字符串 String sl=s0+s0+12+ s0+34+ s0+s0; String s2=s0+s0十56+ s0+78+ s0+s0;sl. concat( s2); s2=s1.trim(); System.out.println(s1.length()+s2.length(); /方法main结束 /类J_Test结束4.10【填空题*】下面程序运行的结果是abcdef。 public class J_Test public static void maoin(S

6、tring args) String s1=abc; String s2=def; S2.toUpperCase(); S1.concat(s2); System.out.println(s1+s2); /方法main结束 /类J_Test结束 4.11【填空题*】下面程序运行的结果是javajavaC。 public class J_Test public static void mb_method(String s,StringBuffer t) s=s.replace(j,i); t=t.append(C); /方法mb_method结束 public static void main(

7、String args) String a=new String(java); StringBuffer b=new StringBuffer(java); mb_method(a,b); System.out.println(a+b); / 方法main结束 /类J_Test结束4.12【填空题*】下面程序的输出是A,B。 public class J_Test public static void mb_method(String x,String y) x.concat(y); y=x; /方法mb_method结束 public static void main(String args

8、) String a=new String(A); String b=new String(B); mb_method(a,b); System.out.println(a+,+b); /方法main结束 /类J_Test结束4.13【填空题*】下面程序的输出是AB,B。 public class J_Test public class void mb_method(StringBuffer x,StringBuffer y) x.append(y); y=x; /方法mb_method结束 public static void main(String args) StringBuffer a

9、=new StringBuffer(A); StringBuffer b=new StringBuffer(B); mb_method(a,b); System.out.println(a+.+b); /方法mian结束 /类J_Test结束4.14【填空题*】下面程序的输出是123456。 public class J_Test public static void mb_method(String s,StringBuffer b) String s1=s.replace(1,9); String s2=s.replace(2,8); b.append(56); /方法mb_method结

10、束 public static void main(String args) String s=new String(12); StringBUffer b=new StringBuffer(34); mb_method(s,b); System.out.println(s+b); /方法main结束 类J_Test结束4.15【填空题*】类String本身负责维护一个字符串池。该字符串池存放字符串常量所指向的字符串实例,以及调用过类String成员方法intern后的字符串 实例。4.16【填空题*】按异常在编译时是否被检测来分,异常可以分成两大类: 受检异常(Checked Excepti

11、on)和非受检异常(Unchecked Exception)。4.17【填空题*】请填写下面两处的空白使得下面的方法产生一个异常。 void mb_method()throws Exception thrownew Exception(Exception in mb_method(); /方法mb_method结束4.18【填空题*】运行下面的程序,结果一般会输出14. public class J_Test public static void main(String args) Try System.out.println(1); if(true) Return; Catch(Runtim

12、eException e1) System.out.println(3); Return; finally System.out.println(4); /try/catch/finally结构结束 System.out.println(“End”); /方法main结束 类J_Test结束4.19【填空题*】运行下面的程序,结果一般会输出1。 public class J_Test public static void main(String args) try System.out.print(1); if(true) System.out.print(0); catch(RuntimeE

13、xception e1) System.out.print(2); Return; Catch(Exception e2) System.out.print(3); Return; finally System.out.print(4) /try/catch/finally结构结束 System.out.println(End); /方法main结束 /类J_Test结束4.20【填空题*】运行下面的程序,结果一般会输出2:0,3:4,4:4,5:4。 public class J_Test public static void main(String args) int i=0; try i

14、f(i%3=0) throw new Exception(); System.out.print(1:+i+.); catch(Exception e2) System.out.print(2:+i+.); i+=2; if(i%3=2) throw new Exception(); Return; finally i*=2; System.out.print(3:+i+.); /内部:try/catch/finally结构结束 /for循环结束 catch(Exception e2) System.out.print(4:+i+.); Return; finally System.out.p

15、rint(5:+i+.); /外部:try/catch/finally结构结束 System.out.println(End); /方法main结束 类J_Test结束4.21【填空题*】当下面程序的输入是“1 2 3 4”时;程序的输出是bcdn; 当下面程序的输入是“1 2 3”时,程序的输出是bcdn。将下面程序的 第2326行删去之后,则当下面程序的输入是“1 2 3 4”时,程序的输出是cmn当下面程序的输入是“1 2 3”时,程序的输出是cmn。 01.class J_Test 02. 03. public static void main(String args) 04. 05.

16、 try 06. 07. mb_method1(args); 08. 09 . Catch(Exception e) 10. 11. System.out.print(m); 12. 13. .out.print(n); 14. /方法main 结束 15. 16. static void mb_method1(String a) 17. 18. try 19. 20. mb_method2(a); 21. System.out.print(a); 22. 23. Catch(Exception e) 24. 25. System.out.print(b); 26. 27. finally 2

17、8. 29. System.out.print(c); 30. 31. System.out.print(d); 32. /方法mb_method1结束 33. 34. static void mb_method2(String a) 35. 36. System.out.println(aa.length); 37. /方法mb_method2结束 38. 39. /类J_Test结束4.22【填空题*】参照下面的类间的继承关系图,写出下面程序的输出cmn。 java.lang.Object java.lang.Throwable java.lang.Error java.lang.Exce

18、ption java.io.IOException java.lang.RuntimeException java.lang.ArithmeticException java.lang.IndexOutOfBoundsException java.lang.ArrayIndexOutOfBoundsExceptionclass J_Test public static void main(String args) try mb_method(); catch(Exception e) System.out.print(m); System.out.print(n);/方法main结束stati

19、c void mb_creatException()throw new ArrayIndexOutOfBoundsException();/方法mb_creatException结束static void mb_method() try mb_createException(); System.out.print(“a”); catch(ArithmeticException e) System.out.print(“b”); finally System.out.print(“c”);System.out.print(“d”);/方法mb_method结束类J_Test结束4.23填空题*参

20、照下面的类间的继承关系图,写出下面程序的输出bcdn. java.lang.Object java.lang.Throwable java.lang.Error java.lang.Exception java.io.IOException java.lang.RuntimeException java.lang.ArithmeticException java.lang.IndexOutOfBoundsException java.lang.ArrayIndexOutOfBoundsExceptionclass J_Test public static void main(String ar

21、gs) try mb_method(); catch (Exception e) System.out.print(m); System.out.print(n); /方法main结束 static void mb_createException() throw new ArrayIndexOutOfBoundsException(); /方法mb_createException结束 static void mb_method() try mb_createException(); System.out.print(“a”); catch(Exception e) System.out.pri

22、nt(“b”); finally System.out.print(“c”); System.out.print(“d”); /方法mb_method结束/类J_Test结束72.Java程序设计习题集(含参考答案)424填空题*下面程序输出13423.public class J_Test public static void mb_method(int i) try if(i=1) throw new Exception(); System.out.print(“1”); catch(Exception e) System.out.print(“2”); return; finally S

23、ystem.out.print(“3”); System.out.print(“4”); /方法mb_method结束 public static void main(String args) mb_method(0); mb_method(1); /方法main结束/类J_Test结束4.25填空题*下面程序输出134. public class J_Test public static void mb_method() throw new RuntimeException(); /方法mb_method结束 public static void main(String args) try

24、mb_method(); catch(RuntimeException e) System.out.print(“1”); catch(Exception e1) System.out.print(“2”); finally System.out.print(“3”); System.out.print(“4”); /方法main结束/类J_Test结束4.26填空题*运行下面的程序,并输入字符0,请问运行结果34.import java.io.*;class J_Exception extends Exception/类J_Exception结束public class J_Example

25、public static void main(String args) try int i=System.in.read(); if(i=0) throw new J_Exception(); System.out.print(“1”); catch(IOException e) System.out.print(“2”); catch(J_Exception e)System. out. print(“3”);System. out. print(“4n);/方法main结束/类J_Example结束4. 27 填空题*下面程序输出1245。public class J_Examplepu

26、blic static void main(String args )trytryint l= 1/0;catch(Exception e)System. out. print(l);finallySystem. out. print(”2);catch(Exception e)System. out. print(3);finallySystem, out. print(4);System. out. print(”5n);/方法main结束/类J_Example结束4. 28 填空题*下面程序输出12345。public class J_Example public static void

27、 main(String args ) try try int l= 1/0; catch(Exception e) Systera. out. print( 1); throw e; finally System. out. print(”2); catch(Exception e) System.out.print(3); finally System. out. print(“4”); System. out. print(“5n”); /方法main结束/类J_Example结束4. 29选择题*下面哪些语句会发生编译错误?C (A) inta; (B) int b=new int10; (C) int c =new int ; (D) int d =null;4. 30选择题*下面哪些语句会发生编译错误?ABCD (A) int l0a; (B) int l0b=new int5; (C) int c10=new in

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1