NumberFormat nf= NumberFormat.getInstance();  nf.setMaximumFractionDigits(4);  nf.setMinimumFractionDigits(2);  String a = nf.format(3.1415926);  String b = nf.format(2);  Which two are true about the result if the default locale is Locale.US?()A、 The va

题目

NumberFormat nf= NumberFormat.getInstance();  nf.setMaximumFractionDigits(4);  nf.setMinimumFractionDigits(2);  String a = nf.format(3.1415926);  String b = nf.format(2);  Which two are true about the result if the default locale is Locale.US?()

  • A、 The value of b is 2.
  • B、 The value of a is 3.14.
  • C、 The value of b is 2.00.
  • D、 The value of a is 3.141.
  • E、 The value of a is 3.1415.
  • F、 The value of a is 3.1416.
  • G、 The value of b is 2.0000.

相似考题
更多“NumberFormat nf= NumberFormat.getInstance();  nf.setMaximumFractionDigits(4);  nf.setMinimumFractionDigits(2);  String a = nf.format(3.1415926);  String b = nf.format(2);  Which two are true about the result if the default locale is Locale.US?()A、 The val”相关问题
  • 第1题:

    Given:12.NumberFormatnf=NumberFormat.getInstance();13.nf.setMaximumFractionDigits(4);14.nf.setMinimumFractionDigits(2);15.Stringa=nf.format(3.1415926);16.Stringb=nf.format(2);WhichtwostatementsaretrueabouttheresultifthedefaultlocaleisLocale.US?()

    A.Thevalueofbis2.00.

    B.Thevalueofais3.141.

    C.Thevalueofais3.14.

    D.Thevalueofbis2.0000.

    E.Thevalueofais3.1415.

    F.Thevalueofais3.1416.

    G.Thevalueofbis2.


    参考答案:A, F

  • 第2题:

    下列程序的功能是对两个整数进行比较,由考生通过输入窗口分别输入两个整数,程序

    比较出结果。例如:输入第1个整数为12,第2个整数为33。比较结果显示:

    12!=33

    12<33

    12<=33

    程序有多个遗漏和错误。本题要求改一个错,填三个空。

    注意:不改动程序结构,不得增行或删行。

    import javax.swing.JOptionPane;

    public class ex3

    {

    public static void main(String args[])

    {

    String firstNumber, //用户输入第1个字符串

    secondNumber, //户输入第2个字符串

    result; // a string containing the output

    int number1, //较的第1个数

    number2; //的第2个数

    //读用户输入的第1个字符串read first number from user as a string

    firstNumber=

    JOptionPane.showlnputDialog("Enter first integer:");

    //用户输入的第2个字符串read second number from user as a string

    secondNumber=

    JOptionPane.showInputDialog("Enter second integer:");

    //字符串类型转换成整数类型

    number1=Integer.parseInt(firstNumber);

    number2=Integer.parseInt(secondNumber);

    result="";

    if(String.valueOf(numberl)=String.valueOf(number2))

    result=String.valueOf(numberl)+"= ="+String.valueOf(number2);

    if(String.valueOf(number1)!=String.valueOf(number2))

    result=String.valueOf(number1)+" !="+String.valueOf(number2);

    if(String.valueOf(numberl)< String.valueOf(number2))

    result=result+"\n" +String.valueOf(numberl)+"<"

    +String.valueOf(number2);

    if(String.valueOf(numberl)>String.valueOf(number2))

    result=result+"\n" +String.valueOf(numberl)+" >"

    +String.valueOf(number2);

    if(String.valueOf(numberl)<=String.valueOf(number2))

    result=result+"\n"+String.valueOf(numberl)+" <="

    +String.valueOf(number2);

    if(String.valueOf(numberl)>=String.valueOf(number2))

    result=result+"\n"+String.valueOf(numberl)+ ">="

    +String.valueOf(number2);

    ______(null,result,"比较结果",______INFORMATION_MESSAGE);

    //程序正常退出

    ______;

    }

    }


    正确答案:if(String.valueOf(number1= =String.valueOf(number2)) JOptionPane.showMessageDialog JOptionPane System.exit(0)
    if(String.valueOf(number1= =String.valueOf(number2)) JOptionPane.showMessageDialog JOptionPane System.exit(0) 解析:本题综合考查Java语言的数据类型及运算、基本语句和图形用户界面。 if(String.valueOf(number1)=String.valueOf(number2))是题中的错误。两个变量进行比较应该使用双等号,正确的语句是if(String.valueOf(numberl)==String.valueOf(number2))。第1空填写 JOptionPane.showMessageDialog。调用JOptionPane类的showMessageDialog方法显示信息。第2空填写JOptionPane。JOptionPane.INFORMATION_MESSAGE是JOptionPane自带的参数,用来控制显示在信息框上的图标。要显示惊叹号的图标应使用INFORMATION_MESSAGE参数。第3空应填写System.exit(0)。Java中退出程序使用System的exit方法,该方法需要一个整数参数。

  • 第3题:

    下列代码的执行结果是( )。 public class Test{ public static void main String args[]){ String s1=new String("welcome"); String s2=new String("welcome"); System.out.println(s1==s2); System.out.println(s1.equals(s2)); } }

    A.false,false

    B.false,true

    C.true,true

    D.true,false


    正确答案:B

  • 第4题:

    下列程序段的输出是( )。 public class Test { public static void main (String args[ ]) { String ss1 = new String("hello"); String ss2 = new String("hello"); System.out.println(ssl == ss2); System.out.println (ssequals(ss2)); } }

    A.true, false

    B.true, true

    C.false, true

    D.false, false


  • 第5题:

    public class Test {  public static void main (String[]args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.printIn(“baz = ” + baz);  }  }  And the output:  Baz = 2  Which command line invocation will produce the output?()  

    • A、 Java Test 2222
    • B、 Java Test 1 2 3 4
    • C、 Java Test 4 2 4 2
    • D、 Java Test 4 3 2 1

    正确答案:C

  • 第6题:

    11. double input = 314159.26;  12. NumberFormat nf= NumberFormat.getInstance(Locale.ITALIAN);  13. String b;  14. //insert code here  Which code, inserted at line 14, sets the value of b to 3 14.159,26?() 

    • A、 b = nf.parse( input);
    • B、 b = nf.format( input);
    • C、 b = nf.equals( input);
    • D、 b = nf.parseObject( input);

    正确答案:B

  • 第7题:

    Which two statements are true regarding L2TP? ()(Choose two.)

    • A、Tunnels are initiated by the LAC
    • B、Tunnels are initiated by the LNS
    • C、By default, subscriber authentication occurs on the LNS
    • D、By default, subscriber authentication occurs on the LAC

    正确答案:A,C

  • 第8题:

    Given: 11.double input = 314159.26; 12.NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN); 13.String b; 14.//insert code here Which code, inserted at line 14, sets the value of b to 314.159,26?()

    • A、b = nf.parse( input );
    • B、b = nf.format( input );
    • C、b = nf.equals( input );
    • D、b = nf.parseObject( input );

    正确答案:B

  • 第9题:

    单选题
    Given: 11.double input = 314159.26; 12.NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN); 13.String b; 14.//insert code here Which code, inserted at line 14, sets the value of b to 314.159,26?()
    A

    b = nf.parse( input );

    B

    b = nf.format( input );

    C

    b = nf.equals( input );

    D

    b = nf.parseObject( input );


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

  • 第10题:

    单选题
    11. double input = 314159.26;  12. NumberFormat nf= NumberFormat.getInstance(Locale.ITALIAN);  13. String b;  14. //insert code here  Which code, inserted at line 14, sets the value of b to 3 14.159,26?()
    A

     b = nf.parse( input);

    B

     b = nf.format( input);

    C

     b = nf.equals( input);

    D

     b = nf.parseObject( input);


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

  • 第11题:

    多选题
    Given:   12. NumberFormat nf = NumberFormat.getInstance();   13. nf.setMaximumFractionDigits(4);   14. nf.setMinimumFractionDigits(2);   15. String a = nf.format(3.1415926);   16. String b = nf.format(2);   Which two statements are true about the result if the default locale is Locale.US?()
    A

    The value of b is 2.00.

    B

    The value of a is 3.141.

    C

    The value of a is 3.14.

    D

    The value of b is 2.0000.

    E

    The value of a is 3.1415.

    F

    The value of a is 3.1416.

    G

    The value of b is 2.


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

  • 第12题:

    多选题
    NumberFormat nf= NumberFormat.getInstance();  nf.setMaximumFractionDigits(4);  nf.setMinimumFractionDigits(2);  String a = nf.format(3.1415926);  String b = nf.format(2);  Which two are true about the result if the default locale is Locale.US?()
    A

    The value of b is 2.

    B

    The value of a is 3.14.

    C

    The value of b is 2.00.

    D

    The value of a is 3.141.

    E

    The value of a is 3.1415.

    F

    The value of a is 3.1416.

    G

    The value of b is 2.0000.


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

  • 第13题:

    Given:11.doubleinput=314159.26;12.NumberFormatnf=NumberFormat.getInstance(Locale.ITALIAN);13.Stringb;14.//insertcodehereWhichcode,insertedatline14,setsthevalueofbto314.159,26?()

    A.b=nf.parse(input);

    B.b=nf.format(input);

    C.b=nf.equals(input);

    D.b=nf.parseObject(input);


    参考答案:B

  • 第14题:

    下列语句能给数组赋值而不使用for循环的是

    A.myArray{[1]="One";[2]="Two";[3]="Three";}

    B.String s[5]=new String[]{"Zero", "One", "Two", "There", "Four"};

    C.String s[]=new String[]{"Zero", "One", "Two", "There", "Four"};

    D.String s[]=new String[]=|"Zero", "One", "Two", "There", "Four"};


    正确答案:C
    解析:A)、D)语法不正确,B)中s[5]的形式只能通过for循环的格式进行赋值,而不能直接赋值。C)中表达式左侧的“[]”说明现在定义一个数组,不需要指明数组长度,而表达式右侧“[]”在后面直接紧跟初始内容时也是不需要指定数组大小的,数组大小直接由初值长度决定。

  • 第15题:

    Which two statements are true about precedence values in policy?() (Choose two.)

    A. 1 is the default precedence.

    B. A lower number is preferred.

    C. A higher number is preferred.

    D. 100 is the default precedence.


    参考答案:B, D

  • 第16题:

    下列语句能给数组赋值,而不使用for循环的是

    A.myArray{[1]="One";[2]="Two";[3]="Three";}

    B.String s[5]=new String[] {"Zero","One","Two","Three","Four"};

    C.String s[]=new String[] {"Zero","One","Two","Three","Four"};

    D.String s[]=new String[]= {"Zero","One","Two","Three","Four"};


    正确答案:C
    解析:字符串数组赋初值的方法有两种,一种是如选项C一样初始化。另外一种是先为每个数组元素分配引用空间,再为每个数组元素分配空间并赋初值。例如还可做如下赋值:
      string s[]=new String[5];
      s[0]="Zero";
      s[1]="One";
      s[2]="Two";
      s[3]="Three";
      s[4]="Four";

  • 第17题:

    public class X {  public static void main (String[]args)  {  String s1 = new String (“true”);  Boolean b1 = new Boolean (true);  if (s2.equals(b1))   {  System.out.printIn(“Equal”);  }  }  }      What is the result?()  

    • A、 The program runs and prints nothing.
    • B、 The program runs and prints “Equal”
    • C、 An error at line 5 causes compilation to fail.
    • D、 The program runs but aborts with an exception.

    正确答案:A

  • 第18题:

    Which is the earliest line in the following code after which the object created on the line marked (0) will be a candidate for being garbage collected, assuming no compiler optimizations are done? ()  public class Q76a9 {   static String f() {   String a = "hello";   String b = "bye"; // (0)   String c = b + "!"; // (1)   String d = b;  b = a; // (2)   d = a; // (3)   return c; // (4)  }   public static void main(String args[]) {   String msg = f();   System.out.println(msg); // (5)   }   }  

    • A、The line marked (1).
    • B、The line marked (2).
    • C、The line marked (3).
    • D、The line marked (4).
    • E、The line marked (5).

    正确答案:C

  • 第19题:

    Which two statements are true about precedence values in policy?() (Choose two.)

    • A、1 is the default precedence.
    • B、A lower number is preferred.
    • C、A higher number is preferred.
    • D、100 is the default precedence.

    正确答案:B,D

  • 第20题:

    Given:   12. NumberFormat nf = NumberFormat.getInstance();   13. nf.setMaximumFractionDigits(4);   14. nf.setMinimumFractionDigits(2);   15. String a = nf.format(3.1415926);   16. String b = nf.format(2);   Which two statements are true about the result if the default locale is Locale.US?()

    • A、 The value of b is 2.00.
    • B、 The value of a is 3.141.
    • C、 The value of a is 3.14.
    • D、 The value of b is 2.0000.
    • E、 The value of a is 3.1415.
    • F、 The value of a is 3.1416.
    • G、 The value of b is 2.

    正确答案:A,F

  • 第21题:

    单选题
    public class Test {  public static void main (String[]args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.printIn(“baz = ” + baz);  }  }  And the output:  Baz = 2  Which command line invocation will produce the output?()
    A

     Java Test 2222

    B

     Java Test 1 2 3 4

    C

     Java Test 4 2 4 2

    D

     Java Test 4 3 2 1


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

  • 第22题:

    多选题
    Given: Which two statements are true about the result if the default locale is Locale.US?()
    A

    The value of b is 2.

    B

    The value of a is 3.14.

    C

    The value of b is 2.00.

    D

    The value of a is 3.141.

    E

    The value of a is 3.1415.

    F

    The value of a is 3.1416.

    G

    The value of b is 2.0000.


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

  • 第23题:

    单选题
    Given: 11.double input = 314159.26; 12.NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN); 13.String b; 14.//insert code here Which code, inserted at line 14, sets the value of b to 314.159,26?()
    A

    b = nf.parse( input );

    B

    b = nf.format( input );

    C

    b = nf.equals( input );

    D

    b = nf.parseObject( input );


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