单选题public class Test {  private static float[] f = new float[2];  public static void main(String args[]) {  System.out.println(“f[0] = “ + f[0]);  }  }   What is the result?()Af[0] = 0Bf[0] = 0.0CCompilation fails.DAn exception is thrown at runtime.

题目
单选题
public class Test {  private static float[] f = new float[2];  public static void main(String args[]) {  System.out.println(“f[0] = “ + f[0]);  }  }   What is the result?()
A

 f[0] = 0

B

 f[0] = 0.0

C

 Compilation fails.

D

 An exception is thrown at runtime.


相似考题
更多“单选题public class Test {  private static float[] f = new float[2];  public static void main(String args[]) {  System.out.println(“f[0] = “ + f[0]);  }  }   What is the result?()A  f[0] = 0B  f[0] = 0.0C  Compilation fails.D  An exception is thrown at runtim”相关问题
  • 第1题:

    public class ArrayTest {  public static void main(String[] args) {  float fl[], f2[];  fl = new float[10];  f2 = f1;  System.out.println(“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 expectation at runtime.

    正确答案:A

  • 第2题:

    public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()  

    • A、 true
    • B、 null
    • C、 false
    • D、 Compilation fails.
    • E、 The code runs with no output.
    • F、 An exception is thrown at runtime.

    正确答案:A

  • 第3题:

    public class Test {  private static float[] f = new float[2];  public static void main(String args[]) {  System.out.println(“f[0] = “ + f[0]);  }  }   What is the result?()  

    • A、 f[0] = 0
    • B、 f[0] = 0.0
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:B

  • 第4题:

    public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()  

    • A、 0
    • B、 1
    • C、 2
    • D、 Compilation fails.

    正确答案:D

  • 第5题:

    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

  • 第6题:

    public class Test {  public static void main(String[] args) {  int x = 0;  assert (x > 0): “assertion failed”;  System.out.println(“finished”);  }  }  What is the result?()  

    • A、 finished
    • B、 Compilation fails.
    • C、 An AssertionError is thrown.
    • D、 An AssertionError is thrown and finished is output.

    正确答案:A

  • 第7题:

    单选题
    public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()
    A

     0

    B

     null

    C

     Compilation fails.

    D

     A NullPointerException is thrown at runtime.

    E

     An ArrayIndexOutOfBoundsException is thrown at runtime.


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

  • 第8题:

    单选题
    public class ArrayTest {  public static void main(String[] args) {  float fl[], f2[];  fl = new float[10];  f2 = f1;  System.out.println(“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 expectation at runtime.


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

  • 第9题:

    单选题
    public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()
    A

     0

    B

     1

    C

     2

    D

     Compilation fails.


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

  • 第10题:

    单选题
    public static void main(String[] args) {  for (int i=0;i6) break;  }  System.out.println(i);  }  What is the result?()
    A

     6

    B

     7

    C

     10

    D

     11

    E

     Compilation fails.

    F

     An exception is thrown at runtime.


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

  • 第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题:

    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

  • 第14题:

    class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  

    • A、 0
    • B、 1
    • C、 2
    • D、 Compilation fails.

    正确答案:C

  • 第15题:

    class TestA {  public void start() { System.out.println(”TestA”); }  }  public class TestB extends TestA {  public void start() { System.out.println(”TestB”); } public static void main(String[] args) {  ((TestA)new TestB()).start();  }  }  What is the result?() 

    • A、 TestA
    • B、 TestB
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:B

  • 第16题:

    public static void main(String[] args) {  try {  args=null;  args[0] = “test”;  System.out.println(args[0]);  } catch (Exception ex) {  System.out.println(”Exception”);  } catch (NullPointerException npe) {  System.out.println(”NullPointerException”);  }  }  What is the result?() 

    • A、 test
    • B、 Exception
    • C、 Compilation fails.
    • D、 NullPointerException

    正确答案:C

  • 第17题:

    public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()   

    • A、 0
    • B、 null
    • C、 Compilation fails.
    • D、 A NullPointerException is thrown at runtime.
    • E、 An ArrayIndexOutOfBoundsException is thrown at runtime.

    正确答案:D

  • 第18题:

    单选题
    public class Test {  private static float[] f = new float[2];  public static void main(String args[]) {  System.out.println(“f[0] = “ + f[0]);  }  }   What is the result?()
    A

     f[0] = 0

    B

     f[0] = 0.0

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


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

  • 第19题:

    单选题
    public static void main(String[] args) {  try {  args=null;  args[0] = “test”;  System.out.println(args[0]);  } catch (Exception ex) {  System.out.println(”Exception”);  } catch (NullPointerException npe) {  System.out.println(”NullPointerException”);  }  }  What is the result?()
    A

     test

    B

     Exception

    C

     Compilation fails.

    D

     NullPointerException


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

  • 第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题:

    单选题
    static void test() throws Error {  if (true) throw new AssertionError();  System.out.print(”test “);  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  System.out.print(”elld “);  }  What is the result?()
    A

     end

    B

     Compilation fails.

    C

     exception end

    D

     exception test end

    E

     A Throwable is thrown by main.

    F

     An Exception is thrown by main.


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

  • 第22题:

    单选题
    public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()
    A

     true

    B

     null

    C

     false

    D

     Compilation fails.

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


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

  • 第23题:

    单选题
    public class Test {  public static void add3 (Integer i) {  int val = i.intValue();  val += 3;  i = new Integer(val); }  public static void main(String args[]) {  Integer i = new Integer(0);  add3(i);  System.out.println(i.intValue());  }  }   What is the result? ()
    A

     0

    B

     3

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


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

  • 第24题:

    单选题
    public class Test {  public static void main(String[] args) {  int x = 0;  assert (x > 0): “assertion failed”;  System.out.println(“finished”);  }  }  What is the result?()
    A

     finished

    B

     Compilation fails.

    C

     An AssertionError is thrown.

    D

     An AssertionError is thrown and finished is output.


    正确答案: D
    解析: This question is a bit tricky because it lacks the following information: It should include a statement that says whether or not assertions are enabled. If they are indeed enabled, the 
    correction answer is C. but if they are not, the correct answer is A. Assertions are not enabled by default so if the question is not changed, the most logical answer is A.