public classTest {
public void change(String str,char[] ch) {str= "test ok";ch[0] = 'g';
}public static voidmain(String[] args) {String str= new String("good");char[] ch = {'a','b','c'};Test te= newTest();te.change(str,ch);System.out.print(str+ "and");System.out.print(ch);}
}
2. 当输入为2的时候返回值是多少?
public static int getValue(int i) {int result = 0;switch (i) {case 1:result = result + i;case 2:result = result + i * 2;case 3:result = result + i * 3;}return result;
}
3. 如下代码输出值为多少?
public class Base
{private String baseName = "base";public Base(){callName();}public void callName() {System. out. println(baseName);}static class Sub extends Base{private String baseName = "sub";public void callName(){System.out.println(baseName) ;}}public static void main(String[] args){Base b = new Sub();}
}