A
B
C
D
第1题:
class One { void foo() {} } class Two extends One { //insert method here } Which three methods, inserted individually at line 14, will correctly complete class Two?()
第2题:
Which two code fragments correctly create and initialize a static array of int elements()
第3题:
The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?()
第4题:
Which three form part of correct array declarations?()
第5题:
Which code fragments will succeed in initializing a two-dimensional array named tab with a size that will cause the expression tab[3][2] to access a valid element?() CODE FRAGMENT a: int[][] tab = { { 0, 0, 0 }, { 0, 0, 0 } }; CODE FRAGMENT b: int tab[][] = new int[4][]; for (int i=0; i CODE FRAGMENT c: int tab[][] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CODE FRAGMENT d: int tab[3][2]; CODE FRAGMENT e: int[] tab[] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };
第6题:
Given: 10. class One { 11. void foo() { } 12. } 13. class Two extends One { 14. //insert method here 15. } Which three methods, inserted individually at line 14, will correctly complete class Two?()
第7题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第8题:
A
B
C
D
第9题:
static final int[]a={100,200};
static final int[]a;static{a=new int[2];a[0]=100;a[1]=200;}
static final int[]a=new int[2]{100,200};
static final int[]a;static void int(){a=new int[3];a[0]=100;a[1]=200;}
第10题:
int []x = {1,2,3,4,5};for(int y = 0; y < 6; y++) System.out.println(x[y]);
static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }
for(int y = 10; y < 10; y++)doStuff(y);
void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }
for(int x = 0; x < 1000000000; x++) doStuff(x);
void counter(int i) { counter(++i); }
第11题:
foreach(x) System.out.println(z);
for(int z : x) System.out.println(z);
while( x.hasNext()) System.out.println( x.next());
for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
第12题:
A
B
C
D
E
F
第13题:
10. public class Bar { 11.static void foo(int...x) { 12. // insert code here 13. } 14. } Which two code fragments, inserted independently at line 12, will allow the class to compile?()
第14题:
Which two create an instance of an array?()
第15题:
package sun.scjp; public enum Color { RED, GREEN, BLUE } package sun.beta; // insert code here public class Beta { Color g = GREEN; public static void main( String[] argv) { System.out.println( GREEN); } } The class Beta and the enum Color are in different packages. Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?()
第16题:
Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?() CODE FRAGMENT a: public static void main(String args[]) { if (args.length != 0) System.out.println(args[args.length-1]); } CODE FRAGMENT b: public static void main(String args[]) { try { System.out.println(args[args.length]); } catch (ArrayIndexOutOfBoundsException e) {} } CODE FRAGMENT c: public static void main(String args[]) { int ix = args.length; String last = args[ix]; if (ix != 0) System.out.println(last); } CODE FRAGMENT d: public static void main(String args[]) { int ix = args.length-1; if (ix > 0) System.out.println(args[ix]); } CODE FRAGMENT e: public static void main(String args[]) { try { System.out.println(args[args.length-1]); }catch (NullPointerException e) {} }
第17题:
Which two code fragments are most likely to cause a StackOverflowError?()
第18题:
Which two code fragments correctly create and initialize a static array of int elements?()
第19题:
Code fragment a.
Code fragment b.
Code fragment c.
Code fragment d.
Code fragment e.
第20题:
import sun.scjp.Color.*;
import static sun.scjp.Color.*;
import sun.scjp.Color; import static sun.scjp.Color.*;
import sun.scjp.*; import static sun.scjp.Color.*;
import sun.scjp.Color; import static sun.scjp.Color.GREEN;
第21题:
char ch = 65;
char ch = ’¥65’;
char ch = ’¥0041’;
char ch = ’A’;
char ch = A;
第22题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第23题:
int ia = new int [15];
float fa = new float [20];
char ca = “Some String”;
Object oa = new float[20];
Int ia = (4, 5, 6) (1, 2, 3)
第24题:
static final int[] a = { 100,200 };
static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }
static final int[] a = new int[2] { 100,200 };
static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }