




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Java程序设计测验题复制您的学号: 填空题 *_您的姓名: 填空题 *_您的班级: 单选题 *软工1901软工19021. 有如下代码段,其运行结果为:_class Test public static void main(String args) String s1 = Hello World!; String s2 = new String(Hello World!); if (s1.equals(s2) System.out.println(equal); else System.out.println(not equal); 填空题 *_(答案:equal)2. 有如下代码段,其运行
2、结果为:_class Test public static void main(String args) int x = 5, y; if (x = 0) if (x 0) y = 8; else y = 4; else y = -8; System.out.println(y); 填空题 *_(答案:8)3. 有如下代码段,其运行结果为:_public class Test public static void main(String args) int i, s = 0; int a = 3, 4, 5; for (i = 0; i 10); public static void main
3、(String arg) int i = 10; Test t = new Test(); t.printValue(i); 填空题 *_(答案:The value is 10)6. 有如下代码段,其运行结果为:_class Point static int x; int y;class Test public static void main(String args) Point p1 = new Point(); Point p2 = new Point(); p1.x = 100; p1.y = 200; System.out.print(p2.x + , + p2.y); 填空题 *_
4、(答案:100, 0)7. 有如下代码段,其运行结果为:_public class Test public static void main(String args) int i, j; int a = 2, 3, 9, 4, 5 ; for (i = 0; i a.length - 1; i+) int k = i; for (j = i; j a.length; j+) if (aj ak) k = j; int temp = ai; ai = ak; ak = temp; for (i = 0; i c ? a : c; d = d 2 b ? d : b; System.out.pri
5、ntln(b); 填空题 *_(答案:6)11. 有如下代码段,其运行结果为:_public class Test public static void main(String args) byte A = (byte) 65535; if (A = 65535) System.out.println(Equal); else System.out.println(Not Equal); 填空题 *_(答案:Not Equal)12. 有如下代码段,其运行结果为:_public class Test public static void main(String argv) int anar =
6、 new int3; System.out.println(anar1); 填空题 *_(答案:0)13. 有如下代码段,其运行结果为:_public class Test public static void swap(int a, int b) int t = a; a = b; b = t; public static void main(String args) int x = 11; int y = 22; swap(x, y); System.out.print(x= + x); 填空题 *_(答案:x=11)14. 有如下代码段,其运行结果为:_public class Test
7、 static int j = 2; public static void main(String args) int i = 4; Test t = new Test(); t.amethod(i); System.out.println(i + and + j); public void amethod(int x) x = x * 2; j = j * 2; 填空题 *_(答案:4 and 4)15. 有如下代码段,其运行结果为:_class Counter static int total; int number; Counter() total+; number+; class St
8、atistics public static void main(String args) Counter c = null; for (int i = 1; i 10; i+) c = new Counter(); System.out.println(number = + c.number + / total = + c.total); 填空题 *_(答案:number = 1/ total = 9)16. 有如下代码段,其运行结果为:_class Father String name; int age; public Father(String name, int age) = name; this.age = age; void out() System.out.print(姓名: + name); System.out.print( 年龄: + age); public class Son extends Father String school; public Son(String name, int age) super(name, age); void out() super.out(); System.out.println( 学校
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 卫生院基本公共卫生服务项目自查报告
- DB65T 4045-2017 气象虚拟化数据中心基础资源池建设技术规范
- 智慧+安全政务云数据中心整体解决方案
- 全息影像技术在市场中的应用
- 保健品市场趋势分析与预测
- 智能系统与人类关系-洞察及研究
- 住宅楼工程建设合同3篇
- 胡萝卜购买合同书4篇
- 防养老诈骗基础知识培训课件
- 品牌文化渗透方法-洞察及研究
- 机车故障处理管理办法
- 房屋市政工程有限空间作业安全管理指南
- 布病防培训课件
- 工程造价咨询绿色施工支持措施
- 食品执行标准对照表
- 法律法规师德师风培训内容
- 销售商务礼仪培训课程
- 三七销售培训课件
- 《中国尖锐湿疣临床诊疗指南(2021版)》解读
- 租金费用收取管理制度
- 建筑垃圾处理技术标准(CJJT 134-2019)
评论
0/150
提交评论