中国大学MOOC: 以下程序的运行结果为?public class Test5{ public static void main(String argv[]){ StringBuffer x = new StringBuffer("你好"); myMethod(x); System.out.print("x=" + x); } public static void myMethod(StringBuffer s){ s.append(",Hi"); }}
举一反三
- 请写出以下程序运行结果: public class Main { public Main() { System.out.print("main "); } public Main(String s) { this(); System.out.print("main with "+s); } public static void main(String[] args) { Main main = new Main("wow"); } }
- 下面哪个结果是正确的?() public class Testjava { public static void main(String [] args ){ StringBuffer buf=new StringBuffer("mycode666"); buf.insert(5,"@"); System.out.println(buf.toString()); } }
- (6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }
- 以下代码的输出结果 ? public class Test1{ static int x = 3; static { ++x; } public static void main(String args[]){ System.out.println(x); } static { x++; } }
- 中国大学MOOC: 下列程序运行结果是( )public class demo { public static void main(String[] args) { int x=30; int[] numbers=new int[x]; x=60; System.out.println(numbers.length); }}