自考Java语言程序设计(一)第五章以后课后习题及答案
【免费下载】java答案第五章

5.声明一个具有内部类的类,此内部类只有一个非默认的构造方法;声明另外一个具有内 部类的类,此内部类继承第一个内部类。
//A 类 class A{
class ClassOfA{ public ClassOfA(){
} } } //B 类 public class B{ class ClassOfB extends A.ClassOfA{ public ClassOfB(A b){
}
运行结果:
对全部高中资料试卷电气设备,在安装过程中以及安装结束后进行高中资料试卷调整试验;通电检查所有设备高中资料电试力卷保相护互装作置用调与试相技互术关,系电,力根通保据过护生管高产线中工敷资艺设料高技试中术卷资,配料不置试仅技卷可术要以是求解指,决机对吊组电顶在气层进设配行备置继进不电行规保空范护载高与中带资负料荷试下卷高问总中题体资,配料而置试且时卷可,调保需控障要试各在验类最;管大对路限设习度备题内进到来行位确调。保整在机使管组其路高在敷中正设资常过料工程试况中卷下,安与要全过加,度强并工看且作护尽下关可都于能可管地以路缩正高小常中故工资障作料高;试中对卷资于连料继接试电管卷保口破护处坏进理范行高围整中,核资或对料者定试对值卷某,弯些审扁异核度常与固高校定中对盒资图位料纸置试,.卷保编工护写况层复进防杂行腐设自跨备动接与处地装理线置,弯高尤曲中其半资要径料避标试免高卷错等调误,试高要方中求案资技,料术编试交写5、卷底重电保。要气护管设设装线备备置敷4高、调动设中电试作技资气高,术料课中并3中试、件资且包卷管中料拒含试路调试绝线验敷试卷动槽方设技作、案技术,管以术来架及避等系免多统不项启必方动要式方高,案中为;资解对料决整试高套卷中启突语动然文过停电程机气中。课高因件中此中资,管料电壁试力薄卷高、电中接气资口设料不备试严进卷等行保问调护题试装,工置合作调理并试利且技用进术管行,线过要敷关求设运电技行力术高保。中护线资装缆料置敷试做设卷到原技准则术确:指灵在导活分。。线对对盒于于处调差,试动当过保不程护同中装电高置压中高回资中路料资交试料叉卷试时技卷,术调应问试采题技用,术金作是属为指隔调发板试电进人机行员一隔,变开需压处要器理在组;事在同前发一掌生线握内槽图部内 纸故,资障强料时电、,回设需路备要须制进同造行时厂外切家部断出电习具源题高高电中中源资资,料料线试试缆卷卷敷试切设验除完报从毕告而,与采要相用进关高行技中检术资查资料和料试检,卷测并主处且要理了保。解护现装场置设。备高中资料试卷布置情况与有关高中资料试卷电气系统接线等情况,然后根据规范与规程规定,制定设备调试高中资料试卷方案。
Java语言程序设计课后习题包括答案

Java语言程序设计 (郑莉 )第二章习题答案1.什么是对象、类,它们之间的联系答:1)对象是包括现实世界物体特点的抽象实体,它反响系统为之保存信息和与它交互的能力。
对象是一些属性及服务的封装体,在程序设计领域,能够用“对象=数据+作用于这些数据上的操作”来表示。
现实生活中对象是指客观世界的实体;在程序中对象是指一组变量和有关方法的会集。
2)类是既有相同操作功能和相同的数据格式的对象的会集与抽象!3)两者的关系:对象是类的详尽实例. 。
2.什么是面向对象的程序设计方法它有那些基本特点答:面向对象程序设计从所办理的数据下手,以数据为中心而不是以服务为中心来描述系统。
它把编程问题视为一个数据会集,数据有对于功能而言,拥有更强的牢固性。
它的特点:抽象,封装,继承,多态。
3(无用)4.请讲解类属性、实例属性及其差异。
答:实例属性,由一个个的实例用来储藏全部实例都需要的属性信息,不相同实例的属性值可能会不相同。
5.请讲解类方法、实例属性及其差异。
答:实例方法表示特定对象的行为,在声明时前面不加static修饰符,在使用时需要发送给一个类实例。
类方法也称为静态方法,在方法声明时前面需加static修饰符,类方法表示详尽实例中类对象的共有行为。
差异:实例方法能够直接接见实例变量,调用实例方法,实例方法能够直接接见类变量,调用类方法;类方法能够直接调用类变量和类方法,类方法不能够直接调用实例变量和实例方法;6.类的接见控制符有哪几种详尽含义及其差异。
答:类的接见控制符只有public (公共类)及无修饰符(默认类)两种。
差异:当使用 public修饰符时表示全部其他的类都能够使用此类;当没有修饰符时,则只有与此类处于同一包中的其他类能够使用类。
7类成员的接见控制符有哪几种他们对类成员分别有哪些接见限制的作用答 : 类成员的接见控制符有public,private,protecte及无修饰符.public( 公有的 ): 用 public修饰的成分表示公有的, 也就是它可以被其他任何对象接见( 前提是对累成员所在的类接见有接见权限).Private(保护的 ) :类中限制为private的成员只能被这个类本身接见,在类外不能见。
《Java语言程序设计:基础篇》课后复习题答案-第五章

Chapter5Methods1.At least three benefits:(1)Reuse code;(2)Reduce complexity;(3)Easy to maintain.See the Sections5.2and5.3on how to declare and invoke methods.What is thesubtle difference between“defining a method”and“declaring a variable”?A declaration usually involvesallocating memory to store a variable,but a definitiondoesn’t.2.void3.Yes.return(num1>num2)?num1:num2;4.True:a call to a method with a void return type is always a statement itself.False:a call to a value-returning method is always a component of an expression.5.A syntax error occurs if a return statement is not used to return a value in a value-returning method.You can have a return statement in a void method,whichsimply exits the method.But a return statement cannot return a value such asreturn x+y in a void method.6.See Section5.2.puting a sales commission given the sales amount and the commission ratepublic static double getCommission(double salesAmount,doublecommissionRate)Printing a calendar for a monthpublic static void printCalendar(int month,int year)Computing a square rootpublic static double sqrt(double value)Testing whether a number is even and return true if it ispublic static boolean isEven(int value)Printing a message for a specified number of timespublic static void printMessage(String message,int times)Computing the monthly payment,given the loan amount,number of years,and annual interest rate.public static double monthlyPayment(double loan,intnumberOfYears,double annualInterestRate)Finding the corresponding uppercase letter given a lowercase letter.public static char getUpperCase(char letter)8.Line2:method1is not defined correctly.It does not have a return type or void.Line2:type int should be declared for parameter m.Line7:parameter type for n should be double to match method2(3.4).Line11:if(n<0)should be removed in method,otherwise a compile error is reported.9.public class Test{public static double xMethod(double i,double j){ while(i<j){j--;}return j;}}10.You pass actual parameters by passing the right type of value in the right order.The actual parameter can have the same name as its formal parameter.11."Pass by value"is to pass a copy of the value to the method.(A)The output of the program is0,because the variable max is not changed byinvoking the method max.(B)224248248162481632248163264(C)Before the call,variable times is3n=3Welcome to Java!n=2Welcome to Java!n=1Welcome to Java!After the call,variable times is3(D)12121421i is 512.Just before max is invoked.Space required for the main methodmax: 0Just entering max.Space required for the max methodmax: 0value2: 2 value1: 1Just before max is returnedSpace required for the main methodmax: 0Space required for the max methodmax: 2value2: 2 value1: 1 Space required for the main methodmax: 0Space required for the main methodmax: 0Right after max is returned13.Two methods with the same name,defined in the same class,is called method overloading.It is fine to have same method name,but different parameter types.You cannot overload methods based on return type,or modifiers.14.Methods public static void method(int x)and public static int method(int y)have the same signature method(int).15.Line 7:int n =1is wrong since n is already declared in the method signature.16.True17.(a)34+(int)(Math.random()*(55–34))(b)(int)(Math.random()*1000)(c)5.5+(Math.random()*(55.5–5.5))(d)(char)(‘a’+(Math.random()*(‘z’–‘a’+1))18.Math.sqrt(4)= 2.0Math.sin(2*Math.PI)=0Math.cos(2*Math.PI)=1Math.pow(2,2)= 4.0Math.log(Math.E)=1Math.exp(1)= 2.718Math.max(2,Math.min(3,4))=3 Math.rint(-2.5)=-2.0Math.ceil(-2.5)=-2.0Math.floor(-2.5)=-3.0Math.round(-2.5f)=-2Math.round(-2.5)=-2Math.rint(2.5)= 2.0Math.ceil(2.5)= 3.0Math.floor(2.5)= 2.0Math.round(2.5f)=3Math.round(-2.5)=-2Math.round(Math.abs(-2.5))=3。
Java程序设计各章习题及其答案

Java程序设计各章习题及其答案第一章习题及思考题1、Java程序是由什么组成的?一个程序中必须有public类吗?Java源文件的命名规则是怎样的?答:一个Java源程序是由若干个类组成。
一个Java程序不一定需要有public类:如果源文件中有多个类时,则只能有一个类是public 类;如果源文件中只有一个类,则不将该类写成public也将默认它为主类。
源文件命名时要求源文件主名应与主类(即用public修饰的类)的类名相同,扩展名为.java。
如果没有定义public类,则可以任何一个类名为主文件名,当然这是不主张的,因为它将无法进行被继承使用。
另外,对Applet小应用程序来说,其主类必须为public,否则虽然在一些编译编译平台下可以通过(在BlueJ下无法通过)但运行时无法显示结果。
2、怎样区分应用程序和小应用程序?应用程序的主类和小应用程序的主类必须用public修饰吗?答:Java Application是完整的程序,需要独立的解释器来解释运行;而Java Applet则是嵌在HTML编写的Web页面中的非独立运行程序,由Web浏览器内部包含的Java解释器来解释运行。
在源程序代码中两者的主要区别是:任何一个Java Application 应用程序必须有且只有一个main方法,它是整个程序的入口方法;任何一个Applet小应用程序要求程序中有且必须有一个类是系统类Applet的子类,即该类头部分以extends Applet结尾。
应用程序的主类当源文件中只有一个类时不必用public修饰,但当有多于一个类时则主类必须用public修饰。
小应用程序的主类在任何时候都需要用public来修饰。
3、开发与运行Java程序需要经过哪些主要步骤和过程?答:主要有三个步骤(1)、用文字编辑器notepad(或在Jcreator,Gel, BuleJ,Eclipse, Jbuilder等)编写源文件;(2)、使用Java编译器(如Javac.exe)将.java源文件编译成字节码文件.class;(3)、运行Java程序:对应用程序应通过Java解释器(如java.exe)来运行,而对小应用程序应通过支持Java标准的浏览器(如Microsoft Explorer)来解释运行。
《Java程序设计》教材第五章练习题答案

习题一、选择题1. 面向对象程序设计的基本特征是(BCD)。
(多选)A.抽象B.封装C.继承D.多态2.下面关于类的说法正确的是(ACD)。
(多选)A.类是Java 语言中的一种复合数据类型。
B.类中包含数据变量和方法。
C.类是对所有具有一定共性的对象的抽象。
D.Java 语言的类只支持单继承。
上机指导1.设计银行项目中的注册银行用户基本信息的类,包括账户卡号、姓名、身份证号、联系电话、家庭住址。
要求是一个标准Java类(数据私有,提供seter/getter),然后提供一个toString方法打印该银行用户的信息。
答:源代码请参见“CH05_LAB\src\com\inspur\ch05\BankUser.java”2.设计银行项目中的帐户信息,包括帐户卡号、密码、存款,要求如“练习题1”。
答:源代码请参见“CH05_LAB\src\com\inspur\ch05\Account.java”3.设计银行项目中的管理员类,包括用户名和密码。
要求如“练习题1”。
答:源代码请参见“CH05_LAB\src\com\inspur\ch05\Manager.java”4.创建一个Rectangle类。
添加两个属性width、height,分别表示宽度和高度,添加计算矩形的周长和面积的方法。
测试输出一个矩形的周长和面积。
答:源代码请参见“CH05_LAB\src\com\inspur\ch05\Rectangle.java”5.猜数字游戏:一个类A有一个成员变量v,有一个初值100。
定义一个类,对A类的成员变量v进行猜。
如果大了则提示大了,小了则提示小了。
等于则提示猜测成功。
答:源代码请参见“CH05_LAB\src\com\inspur\ch05\Guess.java”6.编写一个Java程序,模拟一个简单的计算器。
定义名为Computer的类,其中两个整型数据成员num1和num1,编写构造方法,赋予num1和num2初始值,再为该类定义加、减、乘、除等公有方法,分别对两个成员变量执行加减乘除的运算。
《Java语言程序设计:基础篇》课后复习题答案-第五章

Chapter5Methods1.At least three benefits:(1)Reuse code;(2)Reduce complexity;(3)Easy to maintain.See the Sections5.2and5.3on how to declare and invoke methods.What is thesubtle difference between“defining a method”and“declaring a variable”?A declaration usually involvesallocating memory to store a variable,but a definitiondoesn’t.2.void3.Yes.return(num1>num2)?num1:num2;4.True:a call to a method with a void return type is always a statement itself.False:a call to a value-returning method is always a component of an expression.5.A syntax error occurs if a return statement is not used to return a value in a value-returning method.You can have a return statement in a void method,whichsimply exits the method.But a return statement cannot return a value such asreturn x+y in a void method.6.See Section5.2.puting a sales commission given the sales amount and the commission ratepublic static double getCommission(double salesAmount,doublecommissionRate)Printing a calendar for a monthpublic static void printCalendar(int month,int year)Computing a square rootpublic static double sqrt(double value)Testing whether a number is even and return true if it ispublic static boolean isEven(int value)Printing a message for a specified number of timespublic static void printMessage(String message,int times)Computing the monthly payment,given the loan amount,number of years,and annual interest rate.public static double monthlyPayment(double loan,intnumberOfYears,double annualInterestRate)Finding the corresponding uppercase letter given a lowercase letter.public static char getUpperCase(char letter)8.Line2:method1is not defined correctly.It does not have a return type or void.Line2:type int should be declared for parameter m.Line7:parameter type for n should be double to match method2(3.4).Line11:if(n<0)should be removed in method,otherwise a compile error is reported.9.public class Test{public static double xMethod(double i,double j){ while(i<j){j--;}return j;}}10.You pass actual parameters by passing the right type of value in the right order.The actual parameter can have the same name as its formal parameter.11."Pass by value"is to pass a copy of the value to the method.(A)The output of the program is0,because the variable max is not changed byinvoking the method max.(B)224248248162481632248163264(C)Before the call,variable times is3n=3Welcome to Java!n=2Welcome to Java!n=1Welcome to Java!After the call,variable times is3(D)12121421i is 512.Just before max is invoked.Space required for the main methodmax: 0Just entering max.Space required for the max methodmax: 0value2: 2 value1: 1Just before max is returnedSpace required for the main methodmax: 0Space required for the max methodmax: 2value2: 2 value1: 1 Space required for the main methodmax: 0Space required for the main methodmax: 0Right after max is returned13.Two methods with the same name,defined in the same class,is called method overloading.It is fine to have same method name,but different parameter types.You cannot overload methods based on return type,or modifiers.14.Methods public static void method(int x)and public static int method(int y)have the same signature method(int).15.Line 7:int n =1is wrong since n is already declared in the method signature.16.True17.(a)34+(int)(Math.random()*(55–34))(b)(int)(Math.random()*1000)(c)5.5+(Math.random()*(55.5–5.5))(d)(char)(‘a’+(Math.random()*(‘z’–‘a’+1))18.Math.sqrt(4)= 2.0Math.sin(2*Math.PI)=0Math.cos(2*Math.PI)=1Math.pow(2,2)= 4.0Math.log(Math.E)=1Math.exp(1)= 2.718Math.max(2,Math.min(3,4))=3 Math.rint(-2.5)=-2.0Math.ceil(-2.5)=-2.0Math.floor(-2.5)=-3.0Math.round(-2.5f)=-2Math.round(-2.5)=-2Math.rint(2.5)= 2.0Math.ceil(2.5)= 3.0Math.floor(2.5)= 2.0Math.round(2.5f)=3Math.round(-2.5)=-2Math.round(Math.abs(-2.5))=3。
Java课后题-第5章答案

一.程序设计题1.定义一个汽车类Car,要求如下:1)属性包括:汽车品牌brand(String类型)、颜色color(String类型)和速度speed(double类型),并且所有属性为私有。
2)至少提供一个有参的构造方法(要求品牌和颜色可以初始化为任意值,但速度的初始值必须为0)。
3)为私有属性提供访问器方法。
注意:汽车品牌一旦初始化之后不能修改。
定义测试类CarTest,在其main方法中创建一个品牌为“benz”、颜色为“black”的汽车。
public class Car{private String brand;private String color;private double speed;public Car(String brand,String color){this.brand=brand;this.color=color;}public String getColor(){return color;}public void setColor(String color){this.color=color;}public double getSpeed(){return speed;}public void setSpeed(double speed){this.speed=speed;}public String getBrand(){return brand;}}public class CarTest{public static void main(String[]args){Car c1=new Car("benz","black");}}2.定义一个图书类Book,要求如下:1)属性包括:书名name(String类型)、作者author(String类型),单价price(double类型),数量amount(int类型),并且所有属性为私有。
Java语言程序设计 课后习题+答案

第一章课后习题1.编译Java程序的命令是什么?2.执行Java程序的命令是什么?3.Java应用程序和小程序的区别是什么?4.编写一个application ,实现在屏幕上打印自己名字的功能。
第一章课后习题答案1.编译Java程序的命令是什么?答案:javac 源文件名2.执行Java程序的命令是什么?java 主类名3.Java应用程序和小程序的区别是什么?Java application⏹由Java解释器独立运行字节码⏹由专门的命令行启动程序执行⏹程序中有定义了main()方法的主类Java applet⏹不能独立运行,字节码必须嵌入HTML文档⏹当浏览器调用含applet的Web页面时执行⏹程序中含有java. applet. Applet 类的子类4.编写一个application ,实现在屏幕上打印自己名字的功能。
class Test{public static void main(String[] args){System.out.println(“张三”);}}第二章课后习题(1)一、选择题1.下列变量定义错误的是。
A) int a; B) double b=4.5; C) boolean b=true; D)float f=9.8;2.下列数据类型的精度由高到低的顺序是:a)float,double,int,longb)double,float,int,bytec)byte,long,double,floatd)double,int,float,long3.执行完下列代码后,int a=3;char b='5';char c=(char)(a+b);c的值是?A)’8’ b)53 c)8 d)564.Unicode是一种_____________A) 数据类型 B)java包 C)字符编码 D)java类5.6+5%3+2的值是___________A)2 B)1 C) 9 D)106.下面的逻辑表达式中合法的是__________A)(7+8)&&(9-5) B)(9*5)||(9*7) C)9>6&&8<10 D)(9%4)&&(8*3) 7.java语言中,占用32位存储空间的是__________。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
m_dRealPart = d;
}
void setImaginaryPart(double d)
{
m_dImaginPart = d;
}
//复数运算方法
ComplexNumber complexAdd(ComplexNumber c)
{
return new ComplexNumber(
this.m_dRealPart + c.getRealPart(),
{
suhData=new Data;
}
intgetData()
{
return subData;
}
}
3.“子类的域和方法的数目一定大于等于父类的域和方法的数目”,这种说法是否正确?为什么?
4.在Java程序中,通过类的定义只能实现单重继承()
5.下列哪些说法是正确的?
A、Java语言只允许单一继承
B、Java语言只允许实现一个接口
·m_dlmaginPart虚部,代表复数的虚数部分。
(2)复数类ComplexNumber的方法
·ComplexNumber()构造方法,将实部、虚部都置为0。
·ComplexNumber(doubler,doublei)构造方法,创建复数对象的同时完成复数的实部、虚部的初始化;r为实部的初值,i为虚部的初值。
A.两个或两个以上的方法取相同的方法名,但形参的个数或类型不同考试大论坛
B.两个以上的方法取相同的名字和具有相同的参数个数,但形参的类型可以不同
C.两个以上的方法名字不同,但形参的个数或类型相同
D.两个以上的方法取相同的方法名,并且方法的返回类型相同
3.什么是方法的覆盖?方法的覆盖与域的隐藏有何不同?与方法的重载有何不同?
4. true
5. A D
6. Object
7.答:
What a pleasure!
I am Tom
How do you do?
8.访问权限修饰符
9.“.”
10.软件模型
自考Java语言程序设计(一)第六章重载与多态课后习题
六、重载与多态
1.判断:接口中的所有方法都没有被实现。()
2.方法重载是指( )
}
public Test(String s){
super(s);
System.out.println("How do you do?");
}
public Test(){
this("I am Tom");
}
} www.E
class TT{
public TT(){
System.out.println("What a pleasure!");
4.答:关键字this指代当前类的当前对象,关键字super指代当前类的直接父类对象。考试大-全国最大教育类网站(www.Examda。com)
5.答:一个类中存在多个同名的方法,称为多态。把抽象功能和目的相同,而具体实现因不同情况而异的方法命名为同名方法,符合面向对象程序设计中抽象、提升概念,封装、隐藏细节的特点,从而提高了程序的简洁性和可读性,降低了类和程序模块直接的相互耦合和依赖。
}
public TT(String s){
this();
System.out.println("I am "+s);
}
}
结果:________
8.父类的成员在子类中的访问权限由决定。
9.对象的使用包括引用对象的成员变量和方法。通过运算符就能实现对对象成员变量的访问和对象
10.Java是面向对象语言,对象是客观事物的,对象与之是一一对应的,它是很具体的概念。
自考Java语言程序设计(一)第五张课后习题及答案
自考Java语言程序设计(一)第五章类的继承课后习题
五、类的继承
l.什么是继承?什么是父类?什么是子类?继承的特性可给面向对象编程带来什么好处?什么是单重继承?什么是多重继承?
2.观察下面的程序片断,指出其中的父类和子类,以及父类和子类的各个域和方法。
+ d + "等于"
+ cNumber_plexMulti(d).toString());
}
}
class ComplexNumber
{
//域
private double m_dRealPart;
private double m_dImaginPart;
//构造方法
ComplexNumber()
6.答:Java程序通过覆盖和重载两种方式来实现多态。覆盖是子类重新定义父类中已有的方法,重载是在一个类内部定义与已存在的方法同名但是参数列表不同的方法。
7.答:
public class ch5_e5_12
{
public static void main(String args[])
{
ComplexNumber cNumber_1 =
9.一个类如何实现接口?实现某接口的类是否一定要重载该接口中的所有抽象方法?
10.接口是否可以被继承?阅读下面的代码,试写出SubInterface中的抽象方法。
interface SupInterface
{
public abstract int supMethod();
}
interface SubInterface extends SupInterface
m_dImaginPart = c.getImaginaryPart();
}
//get,set方法
double getRealPart()
{
return m_dRealPart;
}
double getImaginaryPart()
{
return m_dImaginPart;
}
void setRealPart(double d)
System.out.println(cNumber_1.toString() + "乘"
+ cNumber_2.toString() + "等于"
+ cNumber_plexMulti(cNumber_2).toString());
System.out.println(cNumber_1.toString() + "乘"
+ cNumber_plexAdd(cNumber_2).toString());
System.out.println(cNumber_1.toString() + "加"
+ d + "等于"
+ cNumber_plexAdd(d).toString());
System.out.println(cNumber_1.toString() + "减"
this.m_dImaginPart + c.getImaginaryPart());
}
ComplexNumber complexAdd(double c)
{
return new ComplexNumber(
this.m_dRealPart + c, this.m_dImaginPart);
}
ComplexNumber complexMinus(ComplexNumber c)
4.解释this和super的意义和作用。
5.什么是多态?面向对象程序设计为什么要引人多态的特性?使用多态有什么优点?
6.Java程序如何实现多态?有哪些方式?
7.根据下面的要求编程实现复数类ComplexNumber。
(1)复数类ComplexNumber的属性
·m_dRealPart实部,代表复数的实数部分。
{
return new ComplexNumber(
this.m_dRealPart - c.getRealPart(),
this.m_dImaginPart - c.getImaginaryPart());
}
ComplexNumber complexMinus(double c)
{来源:
return new ComplexNumber(
this.m_dRealPart - c, this.m_dImaginPart);
·getRealPart()获得复数对象的实部。
·getlmaginaryPart()获得复数对象的虚部。
·setRealPart(doubled)把当前复数对象的实部设置为给定的形参的数字。
·setlmaginaryPart(doubled)把当前复数对象的虚部设置为给定形参的数字。
·complexAdd(ComplexNumberc)当前复数对象与形参复数对象相加,所得的结果也是复数值,返回给此方法的调用者。
+ cNumber_2.toString() + "等于"
+ cNumber_plexMinus(cNumber_2).toString());
System.out.println(cNumber_1.toString() + "减"
+ d + "等于"
+ cNumber_plexMinus(d).toString());
·complexAdd(doublec)当前复数对象与形参实数对象相加,所得的结果仍是复数值,返回给此方法的调用者。
·complexMinus(ComplexNumberc)当前复数对象与形参复数对象相减,所得的结果也是复数值,返回给此方法的调用者。