




已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
一 单选题一 单选题 1 1 在下列概念中 在下列概念中 JavaJava 语言只保留了语言只保留了 D D A A 运算符重载 运算符重载B B 结构和联合 结构和联合C C 指针 指针D D 方法重载方法重载 2 2 下列类定义中 不正确的是下列类定义中 不正确的是 B B A A classclass x x B B staticstatic classclass x x implementsimplements y1 y2y1 y2 C C publicpublic classclass x x extendsextends AppletApplet D D classclass x x extendsextends y y 3 3 下列语句序列执行后 下列语句序列执行后 k k 的值是的值是 B B intint m 3 m 3 n 6 n 6 k 0 k 0 while while m m y y x x z z B B z z y y x x C C x x y y D D x x y y b B intB int x x b b x x System System outout println b println b b b classclass A A extendsextends B B intint a a A intA int x x intint y y super x super x a a y y System System outout println b println b b b a a a a publicpublic classclass TestTest publicpublic staticstatic voidvoid main String main String args args A A objobj newnew A 13 A 13 23 23 答案答案 b 13b 13 b 13b 13 a 23a 23 2 2 publicpublic classclass Test1Test1 publicpublic staticstatic voidvoid main String main String agrs agrs ABAB s s newnew AB Hello AB Hello I I lovelove JAVA JAVA System System outout println s toString println s toString classclass ABAB StringString s1 s1 StringString s2 s2 AB StringAB String str1 str1 StringString str2 str2 s1s1 str1 str1 s2s2 str2 str2 publicpublic StringString toString toString returnreturn s1s1 s2 s2 答案答案 Hello IHello I lovelove JAVA JAVA 3 3 publicpublic classclass TestTest publicpublic staticstatic voidvoid main String main String args args int int num1num1 newnew int 2 3 int 2 3 num1 0 0 num1 0 0 3 3 num1 0 1 num1 0 1 9 9 num1 0 2 num1 0 2 60 60 num1 1 0 num1 1 0 78 78 num1 1 1 num1 1 1 79 79 forfor int int i i 0 0 i i 1 1 i i forfor int int j j 0 0 j j num1 i length num1 i length j j System System outout print num1 i j print num1 i j t t System System outout println println 答案答案 3 39 96060 787879790 0 4 4 publicpublic classclass TestTest publicpublic staticstatic voidvoid main String main String agrs agrs intint i i s s 0 0 intint a a 10 10 20 20 30 30 40 40 50 50 60 60 70 70 80 80 9090 forfor i i 0 0 i i a length a length i i ifif a i a i 3 3 0 0 s s a i a i System System outout println s println s s s 答案答案 s 30s 30 s 90s 90 s 180s 180 5 5 publicpublic classclass Test3Test3 publicpublic staticstatic voidvoid main String main String agrs agrs A A a a newnew A 2 A 2 A A b b newnew A 3 A 3 System System outout println a isEqualTo b println a isEqualTo b classclass A A privateprivate intint privateVar privateVar publicpublic A intA int privateVar privateVar privateVarprivateVar privateVar privateVar booleanboolean isEqualTo AisEqualTo A anotherA anotherA ifif this privateVar this privateVar anotherA privateVar anotherA privateVar returnreturn true true elseelse returnreturn false false 答案答案 falsefalse 6 6 publicpublic classclass TestTest publicpublic staticstatic voidvoid main String main String args args int int num1num1 newnew int 2 3 int 2 3 num1 0 0 num1 0 0 3 3 num1 0 1 num1 0 1 9 9 num1 0 2 num1 0 2 45 45 num1 1 0 num1 1 0 78 78 num1 1 1 num1 1 1 79 79 forfor int int i i 0 0 i i 1 1 i i forfor int int j j 0 0 j j num1 i length num1 i length j j System System outout print num1 i j print num1 i j t t System System outout println println int int num2num2 newnew int int 1 1 2 2 3 3 7 7 8 8 9 9 forfor int int i i 0 0 i i num2 length num2 length i i forfor int int j j 0 0 j j num2 i length num2 i length j j System System outout print num2 i j print num2 i j t t System System outout println println 答案答案 3 39 94545 787879790 0 1 12 23 3 7 78 8 9 9 7 7 publicpublic classclass Test2Test2 publicpublic staticstatic voidvoid main String main String agrs agrs intint i i s s 0 0 intint a a 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 forfor i i 0 0 i i a length a length i i ifif a i a i 3 3 0 0 s s a i a i System System outout println s println s s s 答案答案 s 3s 3 s 9s 9 s 18s 18 8 8 classclass B B intint b b B intB int x x b b x x System System outout println b println b b b classclass A A extendsextends B B intint a a A intA int x x intint y y super x super x a a y y System System outout println b println b b b a a a a publicpublic classclass TestTest publicpublic staticstatic voidvoid main String main String args args A A objobj newnew A 5 A 5 10 10 答案答案 b 5b 5 b 5b 5 a 10a 10 9 9 publicpublic classclass Test4Test4 publicpublic staticstatic voidvoid main String main String agrs agrs trytry methodmethod catchcatch Exception Exception e e System System outout println A println A finallyfinally System System outout println B println B staticstatic voidvoid method method trytry wrenchwrench System System outout println C println C catchcatch ArithmeticException ArithmeticException e e System System outout println D println D finallyfinally System System outout println E println E System System outout println F println F staticstatic voidvoid wrench wrench throwthrow newnew NullPointerException NullPointerException 答案答案 E E A A B B 五 阅读程序五 阅读程序 回答问题回答问题 1 1 1 1 publicpublic classclass Output1Output1 2 2 publicpublic staticstatic voidvoid main Stringmain String arge arge 3 3 intint i 0 i 0 4 4 forfor charchar chch 97 97 ch 113 ch 113 ch i ch i 5 5 if if i i 8 8 0 0 6 6 System out println System out println 7 7 System out print t System out print t ch ch 8 8 9 9 10 10 1 1 程序第 程序第 5 5 6 6 行的行的 ifif 语句的功能语句的功能是什么 是什么 2 2 程序输出的结果有几行 程序输出的结果有几行 2 2 1 1 importimport java util Arrays java util Arrays 2 2 publicpublic classclass SortArraySortArray 3 3 publicpublic staticstatic voidvoid main Stringmain String args args 4 4 String String strstr size size abs length class abs length class 5 5 Arrays sort str Arrays sort str 6 6 forfor int int i 0 i 0 i str length i str length i i 7 7 System out print str i System out print str i 8 8 9 9 1 1 写出程序运行后的结果 写出程序运行后的结果 2 2 在第 在第 4 4 行和行和 5 5 行之间 进行行之间 进行 str 0 length str 0 length 方法调用的返回结果是多少 方法调用的返回结果是多少 3 3 abstractabstract classclass SuperAbstract SuperAbstract voidvoid a a abstractabstract voidvoid b b abstractabstract intint c intc int i i interfaceinterface AsSuper AsSuper voidvoid x x abstractabstract classclass SubAbstractSubAbstract extendsextends SuperAbstractSuperAbstract implementsimplements AsSuper AsSuper publicpublic voidvoid b b abstractabstract StringString f f publicpublic classclass InheritAbstractInheritAbstract extendsextends SubAbstract SubAbstract publicpublic voidvoid x x publicpublic intint c intc int i i publicpublic StringString f f publicpublic staticstatic voidvoid main Stringmain String args args InheritAbstractInheritAbstract instance newinstance new InheritAbstract InheritAbstract instance x instance x instance a instance a instance b instance b instance c 100 instance c 100 System out println instance f System out println instance f 根据以上这段程序根据以上这段程序 回答问题回答问题 1 1 哪几个类是 哪几个类是抽象类抽象类 写出类名 写出类名 2 2 哪几个类是哪几个类是非抽象类 写出类名 非抽象类 写出类名 3 3 是否有接口 写出接口名 是否有接口 写出接口名 4 4 定义类 定义类 A A 和类和类 B B 如下 如下 classclass A A intint a 1 a 1 doubledouble d 2 0 d 2 0 voidvoid show show System out println ClassSystem out println Class A A a aa a td d td d classclass B B extendsextends A A floatfloat a 3 0f a 3 0f StringString d Javad Java program program voidvoid show show super show super show System out println ClassSystem out println Class B B a aa a td d td d 若在应用程序的若在应用程序的 mainmain 方法中有以下语句 方法中有以下语句 A A a newa new A A a show a show 则输出的结果如何 则输出的结果如何 ClassClass A A a 1a 1d 2 0d 2 0 5 5 写出此程序完成的功能 写出此程序完成的功能 publicpublic classclass SumSum publicpublic staticstatic voidvoid main Stringmain String args args doubledouble sumsum 0 0 0 0 forfor int int i i 1 1 i i 100 100 i i sumsum 1 01 0 double double i i System System outout println sum println sum sum sum 回答问题回答问题 以上程序完成什么功能 以上程序完成什么功能 运行结果是 运行结果是 sum 5 9621sum 5 9621 6 6 写出此程序完成的功能 写出此程序完成的功能 importimport java io java io publicpublic classclass ArrayCountArrayCount publicpublic staticstatic voidvoid main String main String args args intint i i n n 10 10 sumsum 0 0 countcount 0 0 intint a a newnew int 10 int 10 forfor i i 0 0 i i n n i i trytry BufferedReaderBufferedReader brbr newnew BufferedReader newBufferedReader new InputStreamReader System InputStreamReader System inin a i a i Integer Integer parseIntparseInt br readLine br readLine catchcatch IOException IOException e e forfor i i 0 0 i i n n i i sumsum a i a i sumsum n n forfor i i 0 0 i i n n i i ifif a i a i sum sum count count System System outout println count println count 7 7 importimport java util java util publicpublic classclass Test4 Test4 publicpublic staticstatic voidvoid main Stringmain String args args SetSet setset newnew TreeSet TreeSet set add newset add new Integer 10 Integer 10 set add newset add new Integer 5 Integer 5 set add newset add new Integer 15 Integer 15 set add newset add new Integer 5 Integer 5 set add newset add new Integer 10 Integer 10 System System outout println size println size set size set size IteratorIterator itit set iterator set iterator whilewhile it hasNext it hasNext System System outout print it next print it next 1 1 程序运行后输出的结果如何 程序运行后输出的结果如何 sizesize 3 3 5 5 1010 1515 2 2 说明 说明 javajava 中的集合中的集合 Set Set 接口接口 和映射和映射 Map Map 接口接口 的主要区别 的主要区别 8 8 1 1 importimport java applet Applet java applet Applet 2 2 importimport java awt java awt 3 3 importimport java awt event java awt event 4 4 publicpublic classclass TestKeyListenerTestKeyListener extendsextends AppletApplet 5 5 ColorColor clr clr 6 6 publicpublic voidvoid init init 7 7 addKeyListener addKeyListener 8 8 newnew KeyAdapter KeyAdapter 9 9 publicpublic voidvoid keyTyped keyTyped KeyEventKeyEvent e e 10 10 if e getKeyChar r e getKeyChar R if e getKeyChar r e getKeyChar R 11 11 clr Color red clr Color red 12 12 elseelse if e getKeyChar g e getKeyChar G if e getKeyChar g e getKeyChar G 13 13 clr Color green clr Color green 14 14 elseelse if e getKeyChar b e getKeyChar B if e getKeyChar b e getKeyChar B 15 15 clr Color blue clr Color blue 16 16 elseelse 17 17 clr Color black clr Color black 18 18 setBackground clr setBackground clr 19 19 20 20 21 21 22 22 1 1 程序第 程序第 1010 1111 行实现的功能是什么 返回引发键盘事件的按键所对应的行实现的功能是什么 返回引发键盘事件的按键所对应的 UnicodeUnicode 字符 字符 如果为大写如果为大写 R R 或小写或小写 r r 则让变量则让变量 clrclr 等于等于 ColorColor 类类 redred 方法 方法 2 2 编译该程序 并编写嵌入该程序字节码文件的网页后 通过支持 编译该程序 并编写嵌入该程序字节码文件的网页后 通过支持 javajava 的浏览器打开网的浏览器打开网 页 如果敲击键盘的页 如果敲击键盘的 b b 键 有什么结果 键 有什么结果 六 程序设计题六 程序设计题 1 1 设计一个设计一个 CalculatorCalculator 类 并完成下列的各方法的程序设计并测试 类 并完成下列的各方法的程序设计并测试 1 1 定义 定义 add add 方法 用来计算两数方法 用来计算两数 a b a b 之和 之和 2 2 定义 定义 sub sub 方法 用来计算两数方法 用来计算两数 a b a b 之差 之差 3 3 定义 定义 mul mul 方法 用来计算两数方法 用来计算两数 a b a b 之积 之积 4 4 定义 定义 div div 方法 用来计算方法 用来计算 a ba b publicpublic classclass kkkk intint a a b b intint add add returnreturn a a b b intint sub sub returnreturn a a b b intint mul mul returnreturn a a b b intint div div ifif b b 0 0 returnreturn a a b b elseelse returnreturn 0 0 publicpublic staticstatic voidvoid main String main String args args kkkk rectrect newnew kk kk rect rect a a 10 10 rect rect b b 6 6 System System outout println println add add rect add rect add System System outout println println sub sub rect sub rect sub System System outout println println mul mul rect mul rect mul System System outout println println div div rect div rect div 2 2 定义一个定义一个 ArrayListArrayList 集合对象 往其中添加随机产生的集合对象 往其中添加随机产生的 0 100 10 之间的之间的 floatfloat 类型数据 类型数据 共添加共添加 1010 个 并打印输出该集合对象中每个元素的值 个 并打印输出该集合对象中每个元素的值 importimport java util ArrayList java util ArrayList importimport java util Iterator java util Iterator publicpublic classclass TestTest publicpublic staticstatic voidvoid main String main String args args ArrayListArrayList listlist newnew ArrayList ArrayList forfor int int i i 0 0 i i 10 10 i i list add i list add i float float Math random 10 Math random 10 for intfor int j 0 j l
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年护士执业资格考试题库(护理伦理学专项)伦理学伦理道德决策案例分析
- 2025年大学移民管理专业题库- 移民汽车与交通工具管理
- 2025年大学社会体育指导与管理专业题库- 校园体育活动赞助运作模式
- 2025年大学工会学专业题库-工会学专业的实验教学
- 2025年大学融合教育专业题库- 融合教育中的学习评估
- 2025年期货从业资格考试法律法规重点题库试卷
- 2025年大学移民管理专业题库- 移民管理与青年就业问题
- 2025年大学融合教育专业题库- 教学设计与融合教育的融合
- 2025年刑法模拟检测试卷(刑法中的法律适用问题解析与案例分析集)
- 2025年大学警卫学专业题库- 防止校园恶作剧与欺凌事件
- 沟通技巧培训课件(共66张PPT)
- 关于成立特种设备安全管理机构的通知(模板)
- 食品添加剂欧盟编码纯中文版
- 全自动生化分析仪advia2400中文操作手册
- 建筑室外围蔽板材(简化)
- YS/T 397-2015海绵锆
- GB/T 3217-1992永磁(硬磁)材料磁性试验方法
- GB/T 2091-2008工业磷酸
- GB/T 19816.2-2005涂覆涂料前钢材表面处理喷射清理用金属磨料的试验方法第2部分:颗粒尺寸分布的测定
- 市政工程工程量计算规范课件
- 隐身技术概述课件
评论
0/150
提交评论