第一范文网 - 专业文章范例文档资料分享平台

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

来源:用户分享 时间:2025/7/28 2:36:13 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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

2014秋季Java程序设计期末考试试卷(A卷)课件.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1ukj335s9y9kfa2517te4mn0g1mmhw00jmz_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top