已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1 Java 练习题 四 运行程序写结果 1 当在命令提示符后输入 java SumTest 4 5 之后 下列程序的输出结果为 4 5 9 public class SumTest public static void main String args int a b sum a Integer parseInt args 0 b Integer parseInt args 1 sum a b System out println a b sum 2 当在命令提示符后输入 java PrintStar 8 之后 下列程序的输出结果为 A12 public class PrintStar public static void main String args int n Integer parseInt args 0 int i for i 1 i n i System out print System out println 3 当在命令提示符后输入 java CalculateTest 5 5 之后 下列程序的输出结果为 10 0 public class CalculateTest public static void main String args float x y x Float parseFloat args 0 if x 1 y x else if 1 x 2 else y 3 x 11 System out println y 4 下列程序的输出结果为 null A11 public class X public static void main String args String names new String 5 for int x 0 x args length x names x args x System out println names 2 5 下列程序的输出结果为 9 5 10 0 8 A12 public class Test public static void main String args System out print 3 5 1 2 56 10 System out print 3 5 1 0 2 56 10 int a 4 3 7 1 System out println a 6 运行结果是 Hi Like B12 public class Test1 String str new String Hi char ch L i k e public static void main String args Test1 ex new Test1 System out print ex str System out print ex ch 7 运行结果是 4 6 8 10 12 14 16 18 20 B12 3 public class Test3 public static void main String args int i for i 3 i 20 i if i 2 0 System out print i 8 运行结果是 0 1 2 3 4 5 6 7 8 9 class Test6 public static void main String args int i for i 0 i 10 i System out print i if i 2 0 continue System out println 9 运行结果是 3 5 7 11 13 17 19 23 29 public class Test14 public static void main String args int n 1 m j i for i 3 i 30 i 2 m int Math sqrt double i for j 2 j m 1 System out print i if n 5 0 System out print n n 10 下列程序的输出结果为 7 8 15 5 8 13 class generalFunction public static int add int x int y return x y 静态方法 public class StaticFunTest public static void main String args int c generalFunction add 7 8 System out print 7 8 c generalFunction fun new generalFunction int d fun add 5 8 System out println 5 8 d Aclass 11 下列程序的输出结果为 Bclass A11 A12 class Aclass void go System out println Aclass public class Bclass extends Aclass void go System out println Bclass public static void main String args 5 Aclass a new Aclass Aclass a1 new Bclass a go a1 go 12 运行结果是 What a pleasure A12 I am I am Lucy Hello public class Test13 extends TT public static void main String args Test13 t new Test13 public Test13 String s super s System out println Hello public Test13 this I am Lucy class TT public TT System out println What a pleasure public TT String s this System out println I am s 13 运行结果是 36 B12 class Test11 class Dog private String name private int age public int step Dog String s int a 6 name s age a step 0 public void run Dog fast fast step public static void main String args Test11 a new Test11 Dog d a new Dog Kate 5 d step 35 d run d System out println d step 14 运行结果是 exception000 finished public class Test10 public static void aMethod throws Exception try throw new Exception catch Exception e System out println exception000 public static void main String args try aMethod catch Exception e System out println exception 7 System out println finished 15 运行结果是 相等相等 B12 public class Test7 public static void main String args String s1 Java program String s2 new String Java program if s1 equals s2 System out println 不相等 else System out println 相等 16 在输入整数的提示后输入 8 在输入符号的提示后输入 那么下列程序的输出结果为 A12 import java util class CharTest public static void main String args Scanner reader n
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 大单元13 寻社会真谛 逐人生价值-历史唯物主义
- 家政保洁岗位招聘笔试题(某大型集团公司)2025年精练试题精析
- 2026秋小学人教版数学四年级上册九月份月考练习卷含答案
- Z检验相关试题及详细答案解析
- 山东省16地市2027届八年级数学第一学期期末复习检测试题含解析
- 2027届陕西省西安市碑林区西北工大附中数学八年级第一学期期末教学质量检测试题含解析
- 学习内驱力比补课更重要
- 2026 解剖学职称考试试题及答案
- 2027届辽宁省抚顺市名校数学七年级第一学期期末质量检测试题含解析
- 2026年电子衡器现状研究及发展前景趋势
- 2026年6月浙江高考选考物理试卷试题真题(含答案详解)
- 环水保监理实施细则
- 江苏水利工程设计概(估)算编制规定2017年修订版
- 污水处理PLC控制系统方案设计指南
- 设施设备维护人员面试题及答案
- 1105 非无菌产品微生物限度检查:2020年版 VS 2025年版对比表
- 医务人员职业暴露试题(附答案)
- 公路施工项目安全风险评估报告范本
- 安静的力量主题班会课件
- 全麻术后导尿管刺激征管理
- 以例启思:高中思想政治教学中案例教学法的深度应用与策略探索
评论
0/150
提交评论