
1:ObjectInputStream ,ObjectOutputStream
2:try{}
3:10
4:多继承
5:new
6:int , char
7:KeyListener
8:Applet
以上答案尽请参考
完整代码如下:
public class Complex {
private float real; //实部
private float imagin;//虚部
public Complex(){//无参默认为(0, 2)
thisreal = 0F;
thisimagin = 2F;
}
public String toString(){//以a+bi的形式输出的复数
return real + "+" + imagin + "i";
}
// a+ bi + (c+ di) = (a+c) + (b+d)i
public static Complex add(Complex c1, Complex c2){//两个复数相加
Complex complex = new Complex();
complexsetReal(c1getReal() + c2getReal());
complexsetImagin(c1getImagin() + c2getImagin());
return complex;
}
// a+ bi == c + di----> a==c, b==d --> it's true
public static boolean equal(Complex c1, Complex c2){//比较两个复数是否相等
return c1getReal() == c2getReal() && c1getImagin() == c2getImagin();
}
//a + bi + f = (a+f) + bi
public static Complex addFloat(Complex c1, float fValue){//复数加一浮点数
c1setReal(c1getReal() + fValue);
return c1;
}
public float getImagin() {
return imagin;
}
public void setImagin(float imagin) {
thisimagin = imagin;
}
public float getReal() {
return real;
}
public void setReal(float real) {
thisreal = real;
}
}
public class Point {
int x;
int y;
public Point() {
}
public Point(int x, int y) {
thisx = x;
thisy = y;
}
public Point(int x) {
thisx = x;
thisy = x;
}
public double distance() {//求当前点到原点的距离
return Mathsqrt((x x + y y));
}
public double distance(int x1, int y1) {//求当前点到(x1,y1)的距离
return Mathsqrt((x-x1)(x-x1) + (y-y1) (y-y1));
}
public double distance(Point other){
int x2 = otherx;
int y2 = othery;
return Mathsqrt((x-x2)(x-x2) + (y-y2) (y-y2));
}
}
以上就是关于Java语言程序设计,填空题全部的内容,包括:Java语言程序设计,填空题、JAVA语言程序设计题请高手回答、java程序设计上机题,求答案等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)