云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 2014秋季Java程序设计期末考试试卷(A卷)课件

2014秋季Java程序设计期末考试试卷(A卷)课件

  • 62 次阅读
  • 3 次下载
  • 2025/6/3 10:25:21

3.(5分)

public class Abc{

public static void main(String[] args){ int[] a = {1,2,3,4,5,6,7,8,9};

装订线 System.out.printf(\ }

static int odds(int[] a){ int s = 0;

for(int i = 0;i

return s; } }

4.(6分) public class A{

public A(){System.out.println(\ public void abc(){System.out.println(\}

class B extends A{

public B(){this(\

public B(String s){System.out.println(\ public void abc(){System.out.println(\ }

class C extends B{

public C(){this(\

public C(String s){System.out.println(\ public void abc(){super.abc(); System.out.println(\ }

public class Test{

public static void main(String args[]){

A a = new C(); a.abc(); }

(1)在程序中,a.abc()调用体现了面向对象的什么技术?(2分) (2)写出程序运行的结果(4分)

5

得分

四、编写程序题(本大题共3小题,共30分)

1. 设S = 1 + 2 + 3 + …,编写程序求出满足S < 5000的S的最大值。(9分)

2. 编写方法double avg(int[] a),求数组a中能被2或3整除的数的平均值,并在main方法中调用测试该方法。(9分)

3. 编写一个日期类Date,具体要求如下:(12分)

(1)数据域:

year表示年,month表示月,day表示日,类型均为int。封装数据域,并提供访问 器和修改器。 (2)构造方法:

默认构造方法Date(),默认值为2000年1月1日。 一般构造方法Date(int year,int month,int day)。

(3)改写toString方法,显示一个日期,格式为“今天是:XXXX年XX月XX日”。 (4)编写计算闰年中任意月份包含天数的方法int getDays()。

6

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

3.(5分) public class Abc{ public static void main(String[] args){ int[] a = {1,2,3,4,5,6,7,8,9}; 装订线 System.out.printf(\ } static int odds(int[] a){ int s = 0; for(int i = 0;i

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com