Code fragment a.
Code fragment b.
Code fragment c.
Code fragment d.
Code fragment e.
第1题:
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) {} }
第2题:
Which two code fragments will execute the method doStuff() in a separate thread?()
第3题:
foreach(x)System.out.println(z);
for(intz:x)System.out.println(z);
while(x.hasNext())System.out.println(x.next());
for(inti=0;i
第4题:
Vector filelist = ((Directory) file).getList();
String[] filelist = file.directory();
Enumeration filelist = file.contents();
String[] filelist = file.list();
Vector filelist = (new Directory(file)).files();
第5题:
A
B
C
D
第6题:
win.setLayout(new BorderLayout()); win.add(but);
win.setLayout(new GridLayout(1, 1)); win.add(but);
win.setLayout(new BorderLayout()); win.add(but, BorderLayout.CENTER);
win.add(but);
win.setLayout(new FlowLayout()); win.add(but);
第7题:
char ch = 65;
char ch = ’¥65’;
char ch = ’¥0041’;
char ch = ’A’;
char ch = A;
第8题:
String s = c.readLine();
char[] c = c.readLine();
String s = c.readConsole();
char[] c = c.readConsole();
String s = c.readLine(%s, name );
第9题:
It fragments and encapsulates all packets in a fragmentation header.
Packets smaller than the fragmentation size are interleaved between the fragments of thelarger packets.
Packets larger than the fragmentation size are always fragmented, and cannot be interleaved,even if the traffic is voice traffic.
It fragments and encapsulates packets that are longer than a configured size, but does not encapsulate smaller packets inside a fragmentation header.
第10题:
A
B
C
D
E
F
第11题:
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} };
第12题:
defragfs
istat
filemon
fileplace
第13题:
Code fragment a.
Code fragment b.
Code fragment c.
Code fragment d.
Code fragment e.
第14题:
String s = c.readLine();
char[ ] c = c.readLine();
String s = c.readConsole();
char[ ] c = c.readConsole();
String s = c.readLine(%s, name );
char[ ] c = c.readLine(%s, name );
第15题:
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; }
第16题:
Code fragment a.
Code fragment b.
Code fragment c.
Code fragment d.
Code fragment e.
第17题:
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;
第18题:
new Thread() { public void run() { doStuff(); } }
new Thread() { public void start() { doStuff(); } }
new Thread() { public void start() { doStuff(); } } .run();
new Thread() { public void run() { doStuff(); } } .start();
new Thread(new Runnable() { public void run() { doStuff(); } } ).run();
new Thread(new Runnable() { public void run() { doStuff(); } }).start();
第19题:
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]);
第20题:
public void m1() { }
protected void m1() { }
private void m1() { }
void m2() { }
public void m2() { }
protected void m2() { }