以下()表达式产生一个0~7之间(含0,7)的随机整数.A、Math.floor(Math.random()*6)B、Math.floor(Math.random()*7)C、Math. floor(Math.random()*8)D、Math.ceil(Math.random()*8)

题目

以下()表达式产生一个0~7之间(含0,7)的随机整数.

  • A、Math.floor(Math.random()*6)
  • B、Math.floor(Math.random()*7)
  • C、Math. floor(Math.random()*8)
  • D、Math.ceil(Math.random()*8)

相似考题
更多“以下()表达式产生一个0~7之间(含0,7)的随机整数.A、Math.floor(Math.random()*6)B、Math.floor(Math.random()*7)C、Math. floor(Math.random()*8)D、Math.ceil(Math.random()*8)”相关问题
  • 第1题:

    函数Math.Floor(15.8)的返回值为16。()


    参考答案:错误

  • 第2题:

    Whichcodedeterminestheintvaluefooclosesttoadoublevaluebar?()

    A.Intfoo=(int)Math.max(bar);

    B.Intfoo=(int)Math.min(bar);

    C.Intfoo=(int)Math.abs(bar);

    D.Intfoo=(int)Math.ceil(bar);

    E.Intfoo=(int)Math.floor(bar);

    F.Intfoo=(int)Math.round(bar);


    参考答案:F

  • 第3题:

    下面程序段的输出结果是______。 public class Test{ public static void main(String args[ ]){ int x,y; x=(int)Math.sqrt(5/2)+(int)Math.random( )*5/2; y=(int)Math.sqrt(3/2)+(int)Math.random( )*3/2; if(x>y) System.out.println("x>y"); else if(x==y) System.out.println("x=y"); else System.out.println("x<y"); } }

    A.x>y

    B.x=y

    C.x<y

    D.编译错误


    正确答案:A
    解析: 本程序中两个赋值语句右边的表达式分别求两个标准函数的值,再进行整除,判断 x和y的大小。Math.sqrt( )方法计算一个数的平方根,Math.random( )方法输出[1,0]之间的随机数,本题中经过两条赋值语句,x=1,y=0。进入分支结构后,满足if条件执行相应的System.out.println("x>y")操作。所以输出结果应该是选项A。

  • 第4题:

    要产生[20,999]之间的随机整数使用哪个表达式?

    A.(int)(20+Math.random()*979)

    B. 20+(int)(Math.random()*980)

    C. (int)Math.random()*999

    D. 20+(int)Math.random()*980


    正确答案:B

  • 第5题:

    要产生[20,999]之间的随机整数可以使用以下哪个表达式?()

    • A、(int)(20+Math.random()*97)
    • B、 20+(int)(Math.random()*980)
    • C、(int)Math.random()*999
    • D、 20+(int)Math.random()*980

    正确答案:B

  • 第6题:

    在Math类中random方法可以产生随机数。如果从1到100之间产生一个随机整数(大于等于1,小于等于100),并赋值给n,那么下面语句正确的是()。

    • A、n=Math.round(Math.random(100))+1;
    • B、n=Math.round(Math.random()*100)+1;
    • C、n=Math.floor(Math.random(100))+1;
    • D、n=Math.floor(Math.random()*100)+1;

    正确答案:D

  • 第7题:

    下列正确的代码分别是?()

    • A、Math.ceil(7.25)===7
    • B、Math.ceil(7.25)===8
    • C、Math.floor(7.25)===7
    • D、Math.floor(7.25)===8

    正确答案:B,C

  • 第8题:

    Math.random()方法用来实现什么功能?下面的语句起到什么作用? (int)(Math.random()*6)+


    正确答案: 1Math.random()用于产生随机数(0到1之间,包含0,但不包含1)。
    上面的表达式表示1到6之间的一个随机整数(包含1及6)。

  • 第9题:

    单选题
    11. double d = Math.random();   Which is true about d after line 11?()
    A

     d >= 1.0

    B

     0.0 <= d < 1.0

    C

     0.0 <= d < Double.MAX_VALUE

    D

     0.0 <= d <= Double.MAX_VALUE

    E

     Double.MIN_VALUE <= d < Double.MAX_VALUE


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

  • 第10题:

    填空题
    Java语言中的方法Math.Random( )返回0到()之间的一个随机小数。

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

  • 第11题:

    单选题
    要产生[20,999]之间的随机整数可以使用以下哪个表达式?()
    A

    (int)(20+Math.random()*97)

    B

     20+(int)(Math.random()*980)

    C

    (int)Math.random()*999

    D

     20+(int)Math.random()*980


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

  • 第12题:

    (难度:中等)Math.random()返回 0(不包括) 至 1(不包括) 之间的随机数

    答案:(no)

  • 第13题:

    doubled=Math.random();Whichistrueaboutdafterline11?()

    A.d>=1.0

    B.0.0<=d<1.0

    C.0.0<=d<Double.MAX_VALUE

    D.0.0<=d<=Double.MAX_VALUE

    E.Double.MIN_VALUE<=d<Double.MAX_VALUE


    参考答案:B

  • 第14题:

    执行int x=(int)(Math.random()*100);语句时,不会出现下列哪个数值?

    A.1

    B.35

    C.48

    D.100


    正确答案:D
    解析:Math.random()方法产生0~1之间的数,所以再乘以100的范围时0~100,但不包括边界0和100。

  • 第15题:

    阅读以下说明和 Java 代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 设计 RGB 方式表示颜色的调色板,进行绘图。其类图如图 6-1 所示。该程序的 Java代码附后。图6-1 类图

    【Java 代码】 //颜色类 class MyColor { private int red ,green, blue; public MyColor( ) { red = o; green = 0; blue = 0; } public MyColor(int red ,int green ,int blue) { this.red = red; this.green = green; this.blue = blue; } //其他方法略 public String toString( ) { return "Red: " + red + "\tGreen: " + green + "\tBlue " + blue; } } //调色板类 class Palette { public int number; / /颜色数 private (1)palette; //颜色表 public Palette( ) { number = 256; palette = new MyColor[number); } public Palette(MyColor[] palette ,int number) { (2)= number; (3)= palette; } //其他方法略 public String toString( ) { String str = ""; for (int i = 0; i < number; i++) { str +=i+ " : " + palette[i] + "\n"; } return str; } //绘图类 class Drawing { public (4) int COLORNUMBER = 16; public static void main(String[] args) { Palette palette; int red ,green ,blue; MyColor[] color = new MyColor[COLORNUMBER]; for (int i = 0; i < COLORNUMBER; i++) { red = (int) (Math.random( ) * 256); green = (int) (Math.random( ) * 256); blue = (int) (Math.random( ) * 256); color [i] = (5) (red ,green ,blue); } palette = new Palette(color ,COLORNUMBER); System.out.println(palette); } }


    正确答案:(1) MyColor[]
    (2) this.number
    (3) this.palette
    (4) static final
    (5) new MyColor

  • 第16题:

    动作语句:math.random()*10表示产生0--10之间的随机数。

    A

    B



  • 第17题:

    Math.random()方法可返回介于()和()之间的一个伪随机数。


    正确答案:0;0

  • 第18题:

    Java语言中的方法Math.Random( )返回0到()之间的一个随机小数。


    正确答案:1

  • 第19题:

    以下()表达式产生一个0~7之间(含0,7)的随机整数。

    • A、Math.floor(Math.random()*6)
    • B、Math.floor(Math.random()*7)
    • C、Math.floor(Math.random()*8)
    • D、Math.ceil(Math.random()*8)

    正确答案:B

  • 第20题:

    11. double d = Math.random();   Which is true about d after line 11?()  

    • A、 d >= 1.0
    • B、 0.0 <= d < 1.0
    • C、 0.0 <= d < Double.MAX_VALUE
    • D、 0.0 <= d <= Double.MAX_VALUE
    • E、 Double.MIN_VALUE <= d < Double.MAX_VALUE

    正确答案:B

  • 第21题:

    单选题
    以下()表达式产生一个0~7之间(含0,7)的随机整数。
    A

    Math.floor(Math.random()*6)

    B

    Math.floor(Math.random()*7)

    C

    Math.floor(Math.random()*8)

    D

    Math.ceil(Math.random()*8)


    正确答案: D
    解析: Math.random()生成0和1之间的随机小数
    Math.random()*7生成0和7之间的随机小数
    Math.random()*7+1生成0和8之间的随机小数
    Math.floor(Math.random()*7)生成0和7之间的随机整数
    Math.floor(Math.random()*7+1)生成0和8之间的随机整数

  • 第22题:

    问答题
    Math.random()方法用来实现什么功能?下面的语句起到什么作用? (int)(Math.random()*6)+

    正确答案: 1Math.random()用于产生随机数(0到1之间,包含0,但不包含1)。
    上面的表达式表示1到6之间的一个随机整数(包含1及6)。
    解析: 暂无解析

  • 第23题:

    判断题
    动作语句:math.random()*10表示产生0--10之间的随机数。
    A

    B


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