多项选择题Which two code fragments correctly create and initialize a static array of int elements?()

A.static final int[] a = { 100,200 };
B.static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }
C.static final int[] a = new int[2]{ 100,200 };
D.static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }


您可能感兴趣的试卷

你可能感兴趣的试题

1.单项选择题

Click the Exhibit button.

What is the result?()

A.Line 26 prints "a" to System.out.
B.Line 26 prints "b" to System.out.
C.An exception is thrown at line 26 at runtime.
D.Compilation of class A will fail due to an error in line 6.

2.多项选择题

Given.

Which two statements are true?()

A.Foo.beta() is a valid invocation of beta().
B.Foo.alpha() is a valid invocation of alpha().
C.Method beta() can directly call method alpha().
D.Method alpha() can directly call method beta().

3.单项选择题

Given:

What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?()

A.It is true that j==i.
B.It is false that j==i.
C.An exception is thrown at runtime.
D.Compilation fails because of an error in line 13.

4.单项选择题

Given:

What is the result?()

A.true true
B.false true
C.true false
D.false false

5.单项选择题

Given:

What creates the appropriate DateFormat object and adds a day to the Date object?()

A.35. DateFormat df = DateFormat.getDateFormat();42. d.setTime( (60 * 60 * 24) + d.getTime());
B.35. DateFormat df = DateFormat.getDateInstance();42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime());
C.35. DateFormat df = DateFormat.getDateFormat();42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime());
D.35. DateFormat df = DateFormat.getDateInstance();42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime());

7.多项选择题Given that c is a reference to a valid java.io.Console object,which two code fragments read a line of textfrom the console?()

A.String s = c.readLine();
B.char[] c = c.readLine();
C.String s = c.readConsole();
D.char[] c = c.readConsole();
E.String s = c.readLine("%s", "name ");

8.单项选择题

Given:
12.String csv = "Sue,5,true,3";
13.Scanner scanner = new Scanner( csv );
14.scanner.useDelimiter(",");15. int age = scanner.nextInt();
What is the result?()

A.Compilation fails.
B.After line 15, the value of age is 5.
C.After line 15, the value of age is 3.
D.An exception is thrown at runtime.

9.多项选择题Which three statements concerning the use of the java.io.Serializable interface are true?()

A.Objects from classes that use aggregation cannot be serialized.
B.An object serialized on one JVM can be successfully deserialized on a different JVM.
C.The values in fields with the volatile modifier will NOT survive serialization and deserialization.
D.The values in fields with the transient modifier will NOT survive serialization and deserialization.
E.It is legal to serialize an object of a type that has a supertype that does NOT implement java.io.Serializable.

10.多项选择题

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.