文本描述
给出以下代码public class Switch1{final static short x=2;public static int y=0;public static void main(String[] args) {for(int z=0;z<4;z++){switch(z){case x:System.out.print(“0″);default:System.out.print(“def”);case x-1:System.out.print(“1″);break;case x-2:System.out.print(“2″);}}}}??class ParentClass{public int doStuff(int x){return x*2;}}public class ChildClass extends ParentClass{public static void main(String[] args){ChildClass cc=new ChildClass();long x=cc.doStuff(7);System.out.println(“x=”+x);}public long doStuff(int x){return x*3;}}?Public static void main(String[] args){X.x=new X();X.x2=m1(x);X.x4=new X();X2=x4;//comment….}Static X m1(X mx){Mx=new X();Return mx;}}以上代码执行到comment处时有多少个可被垃圾收集的对象?给出以下代码Public class TestObj{Public static void main(String[] args){Object o=new Object(){Public boolean equals(Object obj){Return true;}};System.out.println(o.equals(“Fred”));}}请给出结果:()A 运行时抛出异常B TrueC FredD 第三行编译错误?给出以下代码Class Two{Byte x;}Class PassO{Public static void main(String[] args){PassO p=new PassO();P.start();}Void start(){Two t=new Two();System.out.print(t.x+””);Two t2=fix(t);System.out.print(t.x+” ” +t2.x