n = 100;
i.setX( 100 );
o.getY().setX( 100 );
i = new Inner(); i.setX( 100 );
o.setY( i ); i = new Inner(); i.setX( 100 );
i = new Inner(); i.setX( 100 ); o.setY( i );
第1题:
A.Compilation fails.
B.ClassC is displayed.
C.The code runs with no output.
D.An exception is thrown at runtime.
第2题:
当你编译运行下列程序代码,会得到什么结果?
private class Base{ Base(){ int i = 100; System.out.println(i); } }
public class Pri extends Base{ staticint i = 200;
public static void main(String argv[]){ Pri p = new Pri(); System.out.println(i); } }
A.这段代码不能通过编译
B.输出200
C.输出100和200
D.输出100
第3题:
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 int(){a=new int[3];a[0]=100;a[1]=200;}
第4题:
package foo; public class Outer { public static class Inner { } } Which statement is true?()
第5题:
A.编译错误
B.200
C.100200
D.100
第6题:
A.300-100-100-100-100
B.300-300-100-100-100
C.300-300-300-100-100
D.300-300-300-300-100
第7题:
以下程序的调试结果为?
public class Outer{
public String name = "Outer";
public static void main(String argv[]){
Inner i = new Inner();
i.showName();
}
private class Inner{
String name =new String("Inner");
void showName(){
System.out.println(name);
}
}
}
A.输出结果 Outer
B.输出结果 Inner
C.编译错误,因Inner类定义为私有访问
D.在创建Inner类实例的行出现编译错误
第8题:
A.n = 100;
B.i.setX( 100 );
C.o.getY().setX( 100 );
D.i = new Inner(); i.setX( 100 );
E.o.setY( i ); i = new Inner(); i.setX( 100 );
F.i = new Inner(); i.setX( 100 ); o.setY( i );
第9题:
1. public class Outer{ 2. public void someOuterMethod() { 3. // Line 3 4. } 5. public class Inner{} 6. public static void main( String[]argv ) { 7. Outer o = new Outer(); 8. // Line 8 9. } 10. } Which instantiates an instance of Inner?()
第10题:
Which statements can be inserted at the indicated position in the following code to make the program write 1 on the standard output when run?() public class Q4a39 { int a = 1; int b = 1; int c = 1; class Inner { int a = 2; int get() { int c = 3; // insert statement here return c; } } Q4a39() { Inner i = new Inner(); System.out.println(i.get()); } public static void main(String args[]) { new Q4a39(); } }