多选题求平方根方法public static double sqrt (double a)可以传递的参数类型有哪些?()AbyteBfloatCStringDlong

题目
多选题
求平方根方法public static double sqrt (double a)可以传递的参数类型有哪些?()
A

byte

B

float

C

String

D

long


相似考题

3.阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】下面的程序先构造Point类,再顺序构造Ball类。由于在类Ball中不能直接存取类Point中的xCoordinate及yCoordinate属性值,Ball中的toString方法调用Point类中的toString方法输出中心点的值。在MovingBall类的toString方法中,super.toString调用父类Ball的toString方法输出类Ball中声明的属性值。public class Point{private double xCoordinate;private double yCoordinate;public Point 0 }public Point(ouble x, double y){xCoordinate = x;yCoordinate = y;}public String toString(){return "( + Double.toString(Coordinate)+ ","+ Double.toString(Coordinate) + ");}//other methods}public class Ball{(1); //中心点private double radius; //半径private String colour; ///颜色public Ball() { }public Ball(double xValue, double yValue, double r)// 具有中心点及半径的构造方法{center=(2);//调用类Point 中的构造方法radius = r;}public Ball(double xValue, double yValue, double r, String c)// 具有中心点、半径及颜色的构造方法{(3);//调用3个参数的构造方法colour = c;}public String toString(){return "A ball with center" + center, toString() + ", radius"+ Double.toString(radius) + ", colour" + colour;}//other methods}public class MovingBall. (4){private double speed;public MovingBall() { }public MovingBall(double xValue, double yValue, double r, String e, double s){(5);// 调用父类Ball中具有4个参数的构造方法speed = s;}public String toString( ){ return super, toString( ) + ", speed "+ Double.toString(speed); }//other methods}public class Tester{public static void main(String args[]){MovingBall mb = new MovingBall(10,20,40,"green",25);System.out.println(mb);}}

更多“多选题求平方根方法public static double sqrt (double a)可以传递的参数类型有哪些?()AbyteBfloatCStringDlong”相关问题
  • 第1题:

    下列是定义一个接口ITF的程序,在横线处应填入的选项是 ( )public interface ITF{public static final double PI=3.14,public ______ double area(double a,double b);}

    A.interfaee

    B.static

    C.final

    D.abstract


    正确答案:D
    解析:该题考查的是接口的定义。Java中的接口与类相似,但是接口的成员变量应该全部都是静态的和最终的,并且接口中的方法也应该全是抽象的。所以,在本题的定义中,把接口的方法定义为抽象的,应该用选项D。

  • 第2题:

    阅读以下函数说明和Java代码,将应填入(n)处的字句写在对应栏内。

    【说明】

    下面的程序先构造Point类,再顺序构造Ball类。由于在类Ball中不能直接存取类Point中的xCoordinate及yCoordinate属性值,Ball中的toString方法调用Point类中的toStrinS方法输出中心点的值。在MovingBsll类的toString方法中,super.toString调用父类Ball的toString方法输出类Ball中声明的属性值。

    【Java代码】

    //Point.java文件

    public class Point{

    private double xCoordinate;

    private double yCoordinate;

    public Point(){}

    public Point(double x,double y){

    xCoordinate=x;

    yCoordinate=y;

    }

    public String toStrthg(){

    return"("+Double.toString(xCoordinate)+","

    +Double.toString(yCoordinate)+")";

    }

    //other methods

    }

    //Ball.java文件

    public class Ball{

    private (1);//中心点

    private double radius;//半径

    private String color;//颜色

    public Ball(){}

    public Ball(double xValue, double yValue, double r){

    //具有中心点及其半径的构造方法

    center=(2);//调用类Point中的构造方法

    radius=r;

    }

    public Ball(double xValue, double yValue, double r, String c){

    //具有中心点、半径和颜色的构造方法

    (3);//调用3个参数的构造方法

    color=c;

    }

    public String toString(){

    return "A ball with center"+center.toString()

    +",radius "+Double.toString(radius)+",color"+color;

    }

    //other methods

    }

    class MovingBall (4) {

    private double speed;

    public MovingBall(){}

    public MoyingBall(double xValue, double yValue, double r, String c, double s){

    (5);//调用父类Ball中具有4个参数的构造方法

    speed=s;

    }

    public String toString(){

    return super.toString()+",speed"+Double.toString(speed);

    }

    //other methods

    }

    public class test{

    public static void main(String args[]){

    MovingBall mb=new MovingBall(10,20,40,"green",25);

    System.out.println(mb);

    }

    }


    正确答案:(1) Point center (2) new Point(xValueyValue) (3) this(xValueyValuer) (4) extends Ball (5) super(xValueyValuerc)
    (1) Point center (2) new Point(xValue,yValue) (3) this(xValue,yValue,r) (4) extends Ball (5) super(xValue,yValue,r,c) 解析:在类Ball的有参数构造函数中,对成员变量center通过调用Point类的构造方法初始化,而center在类Ball中尚未声明。结合注释可得空(1)是将center变量声明为Point对象引用,故空(1)应填Point。空(2)是调用Point类的构造函数,根据题意,此处应将xValue和yValue作为参数调用类Point的有参数构造函数,故空(2)应填new Point(xValue,yValue)。
    根据注释,空(3)是调用类Ball的有3个参数的构造方法,而其所在方法本身就是类Ball的一个构造方法,因此可用this来调用自身的构造方法,故空(3)应填this(xValue,yValue,r)。
    根据题述“在MovingBall类的toString方法中,super.toString调用父类Ball的toString方法输出类Ball中声明的属性值”,可知类MovingBall是类Ball的子类,因此空(4)应填extends Ball。
    根据注释,空(5)是调用父类Ball中具有4个参数的构造方法,通过super关键字实现,故空(5)应填super(xValue,yValue,r,c)。

  • 第3题:

    下列是定义一个接口ITF的程序,在横线处应填入的选项是( )。 publid interface ITF { public static final double PI=3.14; public______double area(double a,double B) ; }

    A.interface

    B.static

    C.final

    D.abstract


    正确答案:D
    解析:接口中所有的方法都是abstract属性的,即在父类中不定义方法体,而在子类中进行覆盖父类的方法。接口中的变量都必须是staticfinal属性。

  • 第4题:

    在下列方法的定义中,正确的是 ( )

    A.public double x(){..;return false;}

    B.public static int x(double y){...}

    C.void x(doubled){...;return d}

    D.public static x(double a){..}


    正确答案:D

  • 第5题:

    求平方根方法public static double sqrt (double a)可以传递的参数类型有哪些?()

    • A、byte
    • B、float
    • C、String
    • D、long

    正确答案:A,B,D

  • 第6题:

    Which two are valid declarations within an interface definition?() 

    • A、 void methoda();
    • B、 public double methoda();
    • C、 public final double methoda();
    • D、 static void methoda(double d1);
    • E、 protected void methoda(double d1);

    正确答案:A,B

  • 第7题:

    以下声明合法的是()

    • A、default  String  s
    • B、public  final  static  native  int  w( )
    • C、abstract  double  d
    • D、abstract  final  double  hyperbolicCosine( )

    正确答案:B

  • 第8题:

    在可变参数过程中的参数是()类型,因此可以把任何类型的实参传递给该过程。

    • A、Integer
    • B、String
    • C、Variant
    • D、Double

    正确答案:C

  • 第9题:

    Which will declare the method that forces a subclass to implement it?()

    • A、 public double methoda ():
    • B、 static void methoda(double d1) {}
    • C、 public native double methoda ():
    • D、 abstract public foid methoda ():
    • E、 protected void methoda (double d1) {}

    正确答案:D

  • 第10题:

    您已创建一个名为 CalcSalary,将确定 Certkiller.com 员工的薪酬类的责任。CalcSalary 类包括员工的薪酬递增和递减的方法。下面的代码包含在 CalcSalary 类中:()public class CalcSalary {// for promotionspublic static bool IncrementSalary (Employee Emp, double Amount){if (Emp.Status == QuarterlyReview.AboveGoals)Emp.Salary += Amount;return true;

    • A、public delegate bool Salary (Employee Emp, double Amount);
    • B、public bool Salary (Employee Emp, double Amount);
    • C、public event bool Salary (Employee Emp, double Amount);
    • D、public delegate void Salary (Employee Emp, double Amount);

    正确答案:A

  • 第11题:

    单选题
    下列方法定义中,方法头不正确的是()。
    A

    public static x(double a)

    B

    public static int x(double y)

    C

    void x(double d)


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()
    A

     abstract public void methoda ();

    B

     public abstract double inethoda ();

    C

     static void methoda (double dl) {}

    D

     public native double methoda () {}

    E

     protected void methoda (double dl) {}


    正确答案: A
    解析: 暂无解析

  • 第13题:

    求平方根方法publicstaticdoublesqrt(doublea)可以传递的参数类型有哪些?()

    A.byte

    B.float

    C.String

    D.long


    参考答案:A, B, D

  • 第14题:

    阅读以下说明和Java源程序,将应填入(n)处的字句写在答题纸的对应栏内。

    说明

    以下程序的功能是计算三角形、矩形和正方形的面积并输出。

    程序由5个类组成:AreaTest是主类,类Triangle、Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算面积的抽象方法。

    程序

    public class AreaTest{

    public static void main(String args[]){

    Figure[]figures={

    new Triangle(2,3,3),new Rectangle(5,8), new Square(5)

    };

    for(int i=0;i<figures.1ength;i++){

    System.out.println(figures[i]+"area="+figures[i].getArea());

    }

    }

    }

    public abstract class Figure{

    public abstract double SetAJea();

    public class Rectangle extends (1) {

    double height;

    double width;

    public Rectangle(double height,double width){

    this.height=height;

    this.width=width;

    }

    public String toString(){

    return "Rectangle:height="+height+",width="+width+":";

    }

    public double getArea() { return (2);

    } } public class Square extends (3) {

    public Square(double width) {

    (4);

    }

    public String toString() {

    return "Square:width="+width+":";

    } } public class Triangle extends (5). {

    double la;

    double lb;

    double lc;

    public Triangle(double la,double lb,double lc) {

    this.la=la; this.lb=lb; this.lc=lc;

    public String toString(){

    return "Triangle: sides="+la+","+lb+","+lc+":";

    public double getArea() {

    double s=(la+lb+lc)/2.0;

    return Math.sqrt(s*(s-la)*(s-lb)*(s?1c));

    }

    }


    正确答案:(1)Figure (2)height*width (3)Rectangle (4)super(widthwidth) (5)FiguTe
    (1)Figure (2)height*width (3)Rectangle (4)super(width,width) (5)FiguTe 解析:本题以Java语言为载体,考查面向对象程序设计中的三个重要机制——继承、抽象类和动态绑定的应用。本题所解决的问题与试题6一样,有关的详细描述可参见试题6的分析。
    在Java语言中通过在类中定义抽象方法来创建一个抽象类,或者直接将一个类声明为抽象类。
    由于继承关系已经确定,所以第(1)、(3)、(5)空已经确定,分别为Figure、Rectangle和Figure。第(2)空应填height*widthn
    Java中有一个特殊的函数super,用于在派生类中调用其基类的构造函数。利用 super,我们可以借助Rectangle的带有2个参数的构造函数将正方形的边长width传递到Rectangle的height和width中,所以第(4)空应填super(width,width)。

  • 第15题:

    下列程序的执行结果为【 】。include class Point{public:Point(double i, double j)

    下列程序的执行结果为【 】。

    include <iostream. h>

    class Point

    {

    public:

    Point(double i, double j) { x=i; y=j;}

    double Area() const { return 0.0;}

    private:

    double x, y;

    };

    class Rectangle: public Point

    {

    public:

    Rectangle(double i, double j, double k, double 1)

    double Area() const {return w * h;}

    private:

    double w, h;

    };

    Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).

    {

    w=k, h=1

    }

    void fun(Point &s)

    {

    cout<<s. Area()<<end1;

    }

    void main( )

    {

    Rectangle rec(3.0, 5.2, 15.0. 25.0);

    fun(rec)

    }


    正确答案:×
    0 解析:注意本题不同于基类的指针指向派生类对象。Fun函数的形参是Point基类的引用。在可以用基类对象的地方,均可以用派生类替代,完成基类的行为。反之,在使用派生类对象的地方却不能用基类对象代替,这是因为派生类中的某些行为在基类对象中是不存在的。本题调用的是Point类对象的面积函数,其值永远为0。

  • 第16题:

    下面哪个方法与题目中的不是重载方法public int max(int x,int y)

    A.public double max(double x,double y)

    B.publicintmax(intn,int k)

    C.publicintmax(intx,int y, int z)

    D.public double max(double n,double k)


    正确答案:B

  • 第17题:

    Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()

    • A、 abstract public void methoda ();
    • B、 public abstract double inethoda ();
    • C、 static void methoda (double dl) {}
    • D、 public native double methoda () {}
    • E、 protected void methoda (double dl) {}

    正确答案:C

  • 第18题:

    在接口中以下哪条定义是正确的?()

    • A、void methoda();
    • B、public double methoda();
    • C、public final double methoda();
    • D、static void methoda(double d1);
    • E、protected void methoda(double d1);

    正确答案:A,B

  • 第19题:

    下列方法定义中,方法头不正确的是()。

    • A、public static x(double a)
    • B、public static int x(double y)
    • C、void x(double d)

    正确答案:A

  • 第20题:

    public class OuterClass {   private double d1 1.0;   //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()

    • A、 static class InnerOne {  public double methoda() {return d1;}  }
    • B、 static class InnerOne {  static double methoda() {return d1;}  }
    • C、 private class InnerOne {  public double methoda() {return d1;}  }
    • D、 protected class InnerOne {  static double methoda() {return d1;}  }
    • E、 public abstract class InnerOne {  public abstract double methoda();  }

    正确答案:C,E

  • 第21题:

    Which will declare a method that is available to all members of the same package and can be referenced without an instance of the class?()  

    • A、 Abstract public void methoda();
    • B、 Public abstract double methoda();
    • C、 Static void methoda(double d1){}
    • D、 Public native double methoda()  {}
    • E、 Protected void methoda(double d1)  {}

    正确答案:C

  • 第22题:

    多选题
    求平方根方法public static double sqrt (double a)可以传递的参数类型有哪些?()
    A

    byte

    B

    float

    C

    String

    D

    long


    正确答案: A,D
    解析: 暂无解析

  • 第23题:

    多选题
    1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()
    A

    static class InnerOne { public double methoda() { return d1; } }

    B

    static class InnerOne { static double methoda() { return d1; } }

    C

    private class InnerOne { public double methoda() { return d1; } }

    D

    protected class InnerOne { static double methoda() { return d1; } }

    E

    public abstract class InnerOne { public abstract double methoda(); }


    正确答案: C,A
    解析: 暂无解析

  • 第24题:

    单选题
    Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()
    A

     Abstract public void methoda();

    B

     Public abstract double methoda();

    C

     Static void methoda(double d1){}

    D

     Public native double methoda(){}

    E

     Protected void methoda(double d1){}


    正确答案: C
    解析: 暂无解析