java程序设计 实验指导 答案_java程序设计实验指导答案

java程序设计实验指导答案

更多相关问题

Where are the speakers?[A] At a hospital.[B] At a restaurant.[C] At a railway station. [D]

Questions 15 to 18 are based on the following dialogue happened in a bookstore.Why didn't

It can be concluded that______.[A] raising the world's temperature only a few degrees woul

[A] better [B] good [C] well [D] worse

The word "offset" in the second paragraph could be replaced by______.[A] slip into [B] mak

He is assigned tooversee the production of the assembly lines.A. supervise B. watchC. susp

[A] with [B] at [C] by[D] from

Text 3Autonomous robots are able to move and decide by themselves. At a simple level, thes

What does the woman advise the man to do?[A] Call to check his scores.[B] Inquire when the

Spare a Kidney? It is no longer unusual for a spouse or relative to donate a kidney to a l

It can be concluded that______.[A] raising the world's temperature only a few degrees woul

[A] at [B] in [C] on [D] for

What's the author's impression of Alaska?[A] Positive. [B] Negative.[C] Neutral. [D] Funny

According to the article, what is NOT the advantage of being educated at home?[A] Home is

He has a passionate interest in music.A. enthusiastic B. perfectC. practical D. funny

Raymond Chow

The difference between heart robot and ic Hexapod is that______.[A] ic Hexapod can recogni

[A] indicate [B] report [C] announce [D] declare

No one sells organs in the US since it is illegal.A. Right B. WrongC. Not mentioned

[A] to [B] in [C] with [D] into

One of the reasons why the number of kidney donors has risen is that one is better off wit

[A] when [B] before [C] after [D] since

[A] which[B] what [C] who [D] they

Soldiers have toobey orders.A. reply toB. apply for C. abide withD. comply with

What are the two speakers doing?[A] Sending an e-mail. [B] Doing spelling exercise.[C] Cha

You don't have to be dead to donate a kidney, but you had better know the risks before you

It can be concluded that______.[A] raising the world's temperature only a few degrees woul

All of the following gestures encourage communication except______.[A] leaning forward a l

All of the following gestures encourage communication except______.[A] leaning forward a l

What did the man give the woman?[A] His address. [B] His recommendation.[C] His business c

What's the woman's meaning?[A] The man should have seen the doctor earlier.[B] The man sho

He decided to overcome his shortcomings.A. convertB. convict C. conquer D. convey

[A] become[B] became [C] becoming [D] have become

The curious look from the strangers around her made her feel uneasy.A. difficult B. worded

Museums in the Modern World Museums have changed. They are no longer places for the privil

He decided to overcome his shortcomings.A. convertB. convict C. conquer D. convey

David believes that______.[A] robots will be of more and more human characteristics[B] rob

He emphasized a feasible plan which can be accepted by the both sides.A. favorable B. poss

Questions 23 to 25 are based on the following passage on Amsterdam American Hotel.What do

His novel depicts an ambitious American.A. writes B. sketches C. describes D. indicates

What's the man's problem?[A] He is too late to work.[B] The bed was bought in ten days.[C]

Yao

Why does the man offer a lift?[A] Because the woman's home is on his way home.[B] Because

[A] have [B] having [C] had [D] have had

Questions 19 to 22 are based on a conversation between two friends.what's the good news fo

[A] sold [B] sells [C] has sold [D] had sold

Raymond Chow

[A] guilt [B] happiness [C] sadness[D] eagerness

What are the two speakers doing?[A] Sending an e-mail. [B] Doing spelling exercise.[C] Cha

The difference between heart robot and ic Hexapod is that______.[A] ic Hexapod can recogni

[A] sold [B] sells [C] has sold [D] had sold

[A] guilt [B] happiness [C] sadness[D] eagerness

She wore a gorgeous Victorian gown which was said to be worth thousands of dollars.A. beau

Part B Directions:Read the following article in which five people talk about AIDS. For Que

With the development of society, people, especially the young people, ______.

According to the article, what is NOT the advantage of being educated at home?[A] Home is

[A] sold [B] sells [C] has sold [D] had sold

[A] indicate [B] report [C] announce [D] declare

When a person sneezes, we say "God bless you" because______.[A] it's a tradition[B] the pe

[A] at [B] in [C] on [D] for

原创文章,作者:河马题库,如若转载,请注明出处:http://www.jdyjbyxx.net/list1/59447.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java程序设计》课程实验指导书程序代码(答案)(实验三),个人原创,仅供参考与交流。 希望多多交流,共同进步! 实验三 类和对象 一、实验目的: 掌握Java类的结构、类的定义、方法和属性的定义以及对象的实现; 掌握类及其成员修饰符的使用;掌握构造函数的使用;方法的参数传递和返回值的用法; 掌握类变量与实例变量,以及类方法与实例方法的区别。 三、实验内容: 1.定义一个学生类(Student),属性有private的名字(name), public的年龄(age),专业(specialty)和封装name属性的方法:setName(),getName(),getspecialty()编写Application,创建一个学生对象,设置name和age属性值,然后调用一个方法(此方法将对象作为参数传递,在方法中打印出学生的名字name和年龄age)。(学生类仅包含静态成员变量和方法。) 2.定义一个类Point,代表一个点,public属性有x和y,方法有显示点坐标 show(),构造函数有两个参数分别给x,y赋值,在main方法中构造两个对象,再创建一方法(getMiddle)为取两个点构成线段的中点的坐标,参数为2个点对象,调用此方法后得到一个新的点,编写Application,显示该对象的坐标值。 3.定义一个复数(z=x+iy)类Complex,包含: 两个属性:实部x和虚部y 默认构造函数 Complex(),设置x=0,y=0 构造函数:Complex(int i,int j) 显示复数的方法:showComp()将其显示为如: 5+8i或5-8i 的形式。 求两个复数的和的方法:(参数是两个复数类对象,返回值是复数类对象)public Complex addComp(Complex C1,Complex C2) 求两个复数的差的方法:(参数是两个复数类对象,返回值是复数类对象)public Complex subComp(Complex C1,Complex C2) 求两个复数的乘积的方法:(参数是两个复数类对象,返回值是复数类对象,新复数实部=两复数实部乘积-两复数虚部乘积,新复数虚部=两复数实部与虚部交叉乘积之和,)public Complex multiComp(Complex C1,Complex C2) 比较两个复数是否相等的方法(参数是两个复数类对象,返回值是boolean类型)public boolean equalComp(Complex C1,Complex C2) 在Application中测试该类的方法,实部x和虚部y可由main方法参数提供输入。 三、实验要求: 1. 正确地定义类、方法和属性; 2. 学会方法的参数传递和返回值的用法; 3. 熟练使用类及其成员修饰符 4.使用构造函数创建类的对象; 5. 类变量与实例变量,以及类方法与实例方法的使用 6.程序应包括各个被调用方法的执行结果的显示。 7.写出实验报告。要求记录编译和执行Java程序当中的系统错误信息提示,并给出解决办法。(附运行界面、源代码)。 四、实验步骤: 1.(第1题)定义一个学生类(Student)及它的属性和方法;定义主类和main(),在main()方法中创建学生对象,并通过对象调用它的方法setName(),getName(),输出学生的名字name和年龄age。 2. (第2题) 定义类Point及它的属性、方法和构造函数,定义主类和main(),在main()方法中创建两个坐标对象,,并通过对象调用getMiddle方法后得到一个新的点坐标,调用show()显示该对象的坐标值。 3. (第3题)定义一个复数(z=x+iy)类Complex,及它的属性、方法和构造函数;定义主类和main()方法,在main()方法中创建两个复数类Complex对象,并通过复数类对象调用它们的属性和方法,输出方法执行结果。 五、自做实验 1. 构造一个类来描述屏幕上的一个点,该类的构成包括点的x和y两个坐标,以及一些对点进行的操作,包括:取得点的坐标值,对点的坐标进行赋值,编写应用程序生成该类的对象并对其进行操作。 2. 编写实现:有一个三角形类Triangle,成员变量有底边x和另一条边y,和两边的夹角a(0<a<180),a为静态成员,成员方法有两个:求面积s(无参数)和修改角度(参数为角度)。 3. 编写实现: 构造函数为 Triangle(int xx,int yy,int aa) 参数分别为x,y,a赋值 在main方法中构造两个对象,求出其面积,然后使用修改角度的方法,修改两边的夹角,再求出面积值。(提示:求高的方法 h=y*Math.sin(a) ) 注意:构造方法用于对成员变量初始化,无参数的构造方法将成员变量初始化为0值。
Java程序设计》课程实验指导书程序代码(答案)(实验四:java继承与多态),个人原创,仅供参考与交流。 希望多多交流,共同进步! 实验java继承与多态 一、实验目的: 掌握继承、多态的概念与实现方法; 掌握包和接口的定义和使用方法; 了解JAVA语言实现多继承的途径; 二、实验内容: 1.分别编写两个类Point2D,Point3D来表示二维空间和三维空间的点,使之满足下列要求: (1) Point2D有两个整型成员变量x, y (分别为二维空间的X,Y方向坐标),Point2D的构造方法要实现对其成员变量x, y的初始化。 (2)Point2D有一个void型成员方法offset(int a, int b),它可以实现Point2D的平移。 (3)Point3D是Point2D的直接子类,它有有三个整型成员变量x,y,z (分别为三维空间的X,Y,Z方向坐标),Point3D有两个构造方法:Point3D(int x,int y,int z)和Point3D(Point2D p,int z),两者均可实现对Point3D的成员变量x, y,z的初始化。 (4)Point3D有一个void型成员方法offset(int a, int b,int c),该方法可以实现Point3D的平移。 (5)在Point3D中的主函数main()中实例化两个Point2D的对象p2d1,p2d2,打印出它们之间的距离,再实例化两个Point2D的对象p3d1,p3d2,打印出他们之间的距离。 2.定义抽象类Shape,抽象方法为showArea(),求出面积并显示,定义矩形类Rectangle,正方形类Square,圆类 Circle,根据各自的属性,用showArea方法求出各自的面积,在main方法中构造3个对象,调用showArea方法。 定义接口DiagArea,其中包含方法double getDiagonal()求对角线长, double getArea()求面积,定义一个矩形类,实现此接口,并自行扩充成员变量和方法,定义一个正方形类继承矩形类(如矩形有长w和宽h,正方形有边x,并有相应的构造函数,有一个方法中一次直接显示边长、面积和对角线长),在另一类中的主方法里使用测试该类。 三、实验要求: 1. 能实现类的继承关系; 2. 用多种方法创建各个类的对象; 3. 程序应包括各个被调用方法的执行结果的显示。 4. 写出实验报告。要求记录编译和执行Java程序当中的系统错误信息提示,并给出解决办法。(附运行界面、源代码)。 四、实验步骤: 1.(第1题)定义Point2D,及定义它的属性和方法; 定义子类Point3D,及定义它的属性和方法;在Point3D中的主函数main()中实例化两个Point2D的对象,并通过这两个对象调用它们的属性和方法,输出方法执行结果。 2.(第2题)定义抽象类Shape,抽象方法为showArea(),再定义矩形类Rectangle,正方形类Square,圆类 Circle,和各自的属性。定义主类、主方法,在main方法中构造3个对象,调用showArea方法;定义接口DiagArea,其中包含方法double getDiagonal(),在主main方法中输出方法执行结果。 五、自做作实验 1.定义一个描述人的基本类,该类包括人的性别和出生日期两个数据成员,以及设置和获取这些属性值的方法成员;再定义一个大学生类,使大学生类具有人的所有属性外,还具有姓名、学号,大学入学成绩,籍贯属性以及设置和获取这些属性值的方法成员;编写完整的程序,完成一个具有班级学生信息管理功能的程序。 2创建一个接口Shape,其中有抽象方法area,类Circle 、Rectangle实现area方法计算其面积并返回。又有Star实现Shape的area方法,其返回值是0,Star类另有一返回值boolean型方法isStar;在main方法里创建一个Vector,根据随机数的不同向其中加入Shape的不同子类对象(如是1,生成Circle对象;如是2,生成Rectangle对象;如是3,生成Star对象)。然后将Vector中元素依次取出,判断其是否为Star类。如是返回其是个Star。否则返回其面积。 3..学校中有老师和学生两类人,而在职研究生既是老师又是学生,对学生的管理和对教师的管理在他们身上都有体现。 1)设计两个信息管理接口StudentManageInterface和TeacherManageInterface。其中,StudentInterface接口包括setFee()方法和getFee()方法,分别用于设置和获取学生的学费;TeacherInterface接口包括setPay()方法和getPay()方法,分别用于设置和获取教师的工资 2) 定义一个研究生类Graduate,实现StudentInterface接口和TeacherInterface接口,它定义的成员变量有name(姓名)、sex(性别)、age(年龄)、fee(每学期学费)、pay(月工资)。 3) 创建一个姓名为“zhangsan”的研究生,统计他的年收入和学费,如果收入减去学费不足2000元,则输出“provide a loan”(需要贷款)信息。 提示: 1)定义两个接口,分别在其中申明两个方法。 2)定义主类Graduate,实现这两个接口。 3)定义主类的成员变量,和构造方法。 4)给出四个接口方法的实现。 5)给出一个计算是否需要贷款的方法,在里面统计年收入和学费,并输出是否需要贷款的信息。 6)写main方法。在其中创建一个姓名为“zhangsan”的研究生,调用计算是否需要贷款的方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值