更多“单选题float[]f=newfloat[10],则f[0]的值为()A 0.0B 0.0fC nullD false”相关问题
  • 第1题:

    Whichtwocauseacompilererror?()

    A.float[]=newfloat(3);

    B.floatf2[]=newfloat[];

    C.float[]f1=newfloat[3];

    D.floatf3[]=newfloat[3];

    E.floatf5[]={1.0f,2.0f,2.0f};

    F.floatf4[]=newfloat[]{1.0f.2.0f.3.0f};


    参考答案:A, B
    TheF.statementisincorrect.Thefloatnumbersshouldbeseparatedwithcommasandnotdots.

  • 第2题:

    设变量a是int型,f是float型,i是double型,则表达式10+'a'+i*f的值的数据类型为( )。

    A.int

    B.float

    C.double

    D.不确定


    正确答案:C
    解析:int型、float型、double型的数据可以混合,要先转换成同一类型再运算。10+‘a’运算后值的类型为int型,i*f运算后值的类型为double型,最后表达式值的类型为double型。

  • 第3题:

    设变量a是int型,f是float型,i是double型,则表达式10+′a′+i*f值的数据类型为A.int B.float C.double D.不确定


    正确答案:C
    根据混合运算规则,如果有一个数据是float型或double型,则其他数据类型先转化为double型,运算的结果最终也是double型。

  • 第4题:

    float[]f=newfloat[10],则f[0]的值为()

    • A、0.0
    • B、0.0f
    • C、null
    • D、false

    正确答案:B

  • 第5题:

    public static void parse(String str) {  try {  float f= Float.parseFloat(str);  } catch (NumberFormatException nfe) {  f= 0;  } finally {  System.out.println(f);  }  }  public static void main(String[] args) {  parse(”invalid”);  }  What is the result?() 

    • A、 0.0
    • B、 Compilation fails.
    • C、 A ParseException is thrown by the parse method at runtime.
    • D、 A NumberFormatException is thrown by the parse method at runtime.

    正确答案:B

  • 第6题:

    float f[][][] = new float[3][][];  float f0 = 1.0f;  float[][] farray = new float[1][1];  What is valid?()  

    • A、 f[0] = f0;
    • B、 f[0] = farray;
    • C、 f[0] = farray[0];
    • D、 f[0] = farray[0][0];

    正确答案:B

  • 第7题:

    F[x]中,若f(x)+g(x)=3,则f(0)+g(0)=()。

    • A、0.0
    • B、1.0
    • C、2.0
    • D、3.0

    正确答案:D

  • 第8题:

    下面关于float数的定义错误的是()

    • A、float f=-5;
    • B、float f=0x0687;
    • C、float f=1.0;
    • D、float f=7.8f;

    正确答案:C

  • 第9题:

    单选题
    类Teacher:  class Teacher{   String name;   float salary;   Teacher(String name){   this.name = name;  }   Teacher(String name,float salary){   this.name = name;   this.salary = salary;  }  }   执行语句Teacher t = new Teacher(“Tom”,2000.0f);后,字段salary的值是哪一项?()
    A

     2000.0f

    B

     0.0f

    C

     null;

    D

     2000


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

  • 第10题:

    填空题
    float f=-123.567F;inti=(int)f.则i的值现在是()。

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

  • 第11题:

    单选题
    public static void parse(String str) {  try {  float f= Float.parseFloat(str);  } catch (NumberFormatException nfe) {  f= 0;  } finally {  System.out.println(f);  }  }  public static void main(String[] args) {  parse(”invalid”);  }  What is the result?()
    A

     0.0

    B

     Compilation fails.

    C

     A ParseException is thrown by the parse method at runtime.

    D

     A NumberFormatException is thrown by the parse method at runtime.


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

  • 第12题:

    单选题
    public class ArrayTest {   public static void main (Stringargs) {   float f1, f2;   f1 = new float [10];  f2 = f1;   System.out.printIn (“f2[0]=” + f2[0]);   }  }   What is the result?()
    A

     It prints f2[0] = 0.0

    B

     It prints f2[0] = NaN

    C

     An error at line 5 causes compile to fail.

    D

     An error at line 6 causes compile to fail.

    E

     An error at line 6 causes an exception at runtime.


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

  • 第13题:

    publicclassArrayTest{publicstaticvoidmain(Stringargs){floatf1,f2;f1=newfloat[10];f2=f1;System.out.printIn(f2[0]=”+f2[0]);}}Whatistheresult?()

    A.Itprintsf2[0]=0.0

    B.Itprintsf2[0]=NaN

    C.Anerroratline5causescompiletofail.

    D.Anerroratline6causescompiletofail.

    E.Anerroratline6causesanexceptionatruntime.


    参考答案:A

  • 第14题:

    设有定义nit a:float f; double int i,则表达式10+'a'+i+f值的数据类型是( )

    A.int

    B.float

    C.double

    D.不确定


    正确答案:C

  • 第15题:

    float f=-123.567F;inti=(int)f.则i的值现在是()。


    正确答案:-123

  • 第16题:

     public class ArrayTest {   public static void main (Stringargs) {   float f1, f2;   f1 = new float [10];  f2 = f1;   System.out.printIn (“f2[0]=” + f2[0]);   }  }   What is the result?()

    • A、 It prints f2[0] = 0.0
    • B、 It prints f2[0] = NaN
    • C、 An error at line 5 causes compile to fail.
    • D、 An error at line 6 causes compile to fail.
    • E、 An error at line 6 causes an exception at runtime.

    正确答案:A

  • 第17题:

    引用类型的数据字段的缺省值为()

    • A、0.0
    • B、0
    • C、null
    • D、false

    正确答案:C

  • 第18题:

    假定变量x,f和d的类型分别为int 、float和double。下面表达式的值总是为1的是()

    • A、x==(int)(float)x
    • B、d==(double)(float)d
    • C、f==(float)(double)f
    • D、(f+d)-f==d

    正确答案:A

  • 第19题:

    设变量a是整型,f是实型,i是双精度型,则表达式10+’a’+i*f值的数据类型为()。

    • A、不确定
    • B、double
    • C、int
    • D、float

    正确答案:B

  • 第20题:

    1. public class ArrayTest {  2. public static void main (String[]args)  {  3. float f1[], f2[];  4. f1 = new float [10];  5. f2 = f1;  6. System.out.printIn (“f2[0]=” + f2[0]);  7.  }  8. }   What is the result?()  

    • A、 It prints f2[0] = 0.0
    • B、 It prints f2[0] = NaN
    • C、 An error at line 5 causes compile to fail.
    • D、 An error at line 6 causes compile to fail.
    • E、 An error at line 6 causes an exception at runtime.

    正确答案:A

  • 第21题:

    单选题
    1. public class ArrayTest {  2. public static void main (String[]args)  {  3. float f1[], f2[];  4. f1 = new float [10];  5. f2 = f1;  6. System.out.printIn (“f2[0]=” + f2[0]);  7.  }  8. }   What is the result?()
    A

     It prints f2[0] = 0.0

    B

     It prints f2[0] = NaN

    C

     An error at line 5 causes compile to fail.

    D

     An error at line 6 causes compile to fail.

    E

     An error at line 6 causes an exception at runtime.


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

  • 第22题:

    单选题
    假定变量x,f和d的类型分别为int 、float和double。下面表达式的值总是为1的是()
    A

    x==(int)(float)x

    B

    d==(double)(float)d

    C

    f==(float)(double)f

    D

    (f+d)-f==d


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

  • 第23题:

    单选题
    float f[][][] = new float[3][][];  float f0 = 1.0f;  float[][] farray = new float[1][1];  What is valid?()
    A

     f[0] = f0;

    B

     f[0] = farray;

    C

     f[0] = farray[0];

    D

     f[0] = farray[0][0];


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