实验2(01) 类与对象-必做

发布时间 : 星期一 文章实验2(01) 类与对象-必做更新完毕开始阅读

3. 程序运行后的输出是什么? class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 4. 写出程序运行结果 public class Foo { public static void main (String [] args) { StringBuffer a = new StringBuffer (“A”); StringBuffer b = new StringBuffer (“B”); operate(a,b);//调用了Foo类的一个类方法 System.out.printIn(a + “,” +b); } static void operate (StringBuffer x, StringBuffer y) { x.append(y); y = x; } } 5. 解释下面的程序运行结果输出为什么是null public class My { String s; public void My(){ s = \ } public void go() { System.out.println(s); } public static void main(String args[]) { My m = new My(); m.go(); } }

联系合同范文客服:xxxxx#qq.com(#替换为@)