1.下面语句段的输出结果是什么? 
  int i = 9; 
  switch (i) { 
  default: 
  System.out.println("default"); 
  case 0: 
  System.out.println("zero"); 
  break; 
  case 1: 
  System.out.println("one"); 
  case 2: 
  System.out.println("two"); }  A default  B default, zero  C error default clause not defined  D no output displayed 
2、下面哪些选项将是下述程序的输出? 
  public class Outer{
  public static void main(String args[]){
  Outer: for(int i=0; i<3; i++)
   inner:for(int j=0;j<3;j++){
    if(j>1) break;
    System.out.println(j+"and"+i);
   }
  }
  } A 0 and 0  B 0 and 1  C 0 and 2  D 0 and 3  E 2 and 2  F 2 and 1  G 2 and 0 3指出下列程序运行的结果 
public class Example{ 
  String str=new String("good"); 
  char[]ch={'a','b','c'}; 
  public static void main(String args[]){ 
    Example ex=new Example(); 
    ex.change(ex.str,ex.ch); 
    System.out.print(ex.str+" and "); 
    Sytem.out.print(ex.ch); 
  } 
  public void change(String str,char ch[]){ 
    str="test ok"; 
    ch[0]='g'; 
  } 
}  A good and abc  B good and gbc  C test ok and abc  D test ok and gbc4.对于下列代码: 
  1) class Person { 
  2) public void printValue(int i, int j) {//... } 
  3) public void printValue(int i){//... }
  4) } 
  5) public class Teacher extends Person { 
  6) public void printValue() {//... } 
  7) public void printValue(int i) {//...} 
  8) public static void main(String args[]){ 
  9) Person t = new Teacher(); 
  10) t.printValue(10); 
  11) } 
  第10行语句将调用哪行语句??  A line 2  B line 3  C line 6  D line 7

解决方案 »

  1.   

    1,A
    2,A、B、F、G
    3,B
    4,D
      

  2.   

    1、B
    2、A、B、F、G
    3、B
    4、D
      

  3.   

    1,A
    2,ABC
    3,A
    4,D
      

  4.   

    1,b
    2,a b c
    3,b
    4,b
      

  5.   

    1,b
    2,a,1and0,b,1and1,c,1and2
    3,b
    4,d除了第四题,其他都测试过了
      

  6.   

    1.B ;default后都是默认内容,break 跳出;
    2.A,B,C
    3.B
    4.第5行后,怎么没有对应的括号?extends不知道是不是代表继承,就选D吧
      

  7.   

    1,B
    2,ABC   上当了j在前。
    3,B
    4,D
      

  8.   

    答案
    1,B
    2,ABC
    3,B
    4,D
    这就结贴
    拜托答对的给点解释..Thanks!
      

  9.   

    1、B
    2、A、B、F、G
    3、B
    4、D
      

  10.   

    1,i=9  default条件满足,output:defualt, 之后没有break,继续执行,output:zero,
      然后break结束。所以是B。
    2,由于if(j>1) break; j的取值为0和1,
       再由于for(int i=0; i<3; i++) i的取值为0、1、2。
       因为j输出在前,
       所以Output:0,0   A
                   1,0
                   0,1   B
                   1,1
                   0,2   C
                   1,2
      

  11.   

    3,的焦点在:
      public void change(String str,char ch[]){ 
        str="test ok"; 
        ch[0]='g'; 
      } 
    此str非成员变量的str,只是它们的值相等(传值),
    而方法中这个值没被使用str就被赋予了新值,
    注意方法中str的作用域在该方法内,它不影响成员变量。
    而ch[]传的地址,方法改变了地址的内容,成员变量ch的内容也被改变了。
    所以是B。
      

  12.   

    4,子类继承父类,子类复写了方法 7) public void printValue(int i) {//...} 
       new了子类,执行了复写的方法。答案当然是D。