given: class cardboard { short story = 5; cardboard go(cardboard cb) { cb = null; return cb; } public static void main(string[] args) { cardboard c1 = new cardboard(); cardboard c2 = new cardboard(); cardboard c3 = c1.go(c2); c1 = null; // do stuff } } when // dostuff is reached, how many objects of cardboard are null?
如下所示的test类的java程序中,共有几个构造方法()。 public class test{ private int x; public test(){} public void test(int i){ this.x=i; } public test(string str){}}
类 teacher 和 student 是类 person 的子类; teacher t; student s; // t and s are all non-null. if (t instanceof person ){ s=(student)t; } 最后一条语句的结果是:
请阅读以下程序,并写出结果 public class argumentpassing { public static void changevalue(int a) { a = 10; } public static void changevalue(string s1){ s1 = "def"; } public static void changevalue(stringbuffer s1) { s1.append("def"); } public static void main(string[] args) { int a = 5; string b = "abc"; stringbuffer c = new stringbuffer("abc"); changevalue(a); changevalue(b); changevalue(c); system.out.print(a); system.out.print(b); system.out.print(c); } }