Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
第1题:
1. public class GC { 2. private Object o; 3. private void doSomethingElse(Object obj) { o = obj; } 4. public void doSomething() { 5. Object o = new Object(); 6. doSomethingElse(o); 7. o = new Object(); 8. doSomethingElse(null); 9.o=null; 10. } 11. } When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()
第2题:
1.public class GC{ 2.private Objec to; 3.private void doSomethingElse(Object obj){o=obj;} 4.public void doSomething(){ 5.Object o=new Object(); 6.doSomethingElse(o); 7.o=new Object(); 8.doSomethingElse(null); 9.o=null; 10.} 11.} When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()
第3题:
1. public class X ( 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. return oa[0]; 8. } 9. } When is the float object created in line 3, eligible for garbage collection?()
第4题:
1. public class X { 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. oa[0] = null; 10. return o; 9. } 10. } When is the float object created in line 3, eligible for garbage collection?()
第5题:
public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; oa[0] = null; return o; } } When is the float object created in line 3, eligible for garbage collection?()
第6题:
new Inner(); // At line 3
new Inner(); // At line 8
new o.Inner(); // At line 8
new Outer.Inner(); // At line 8
第7题:
for(char o: list)
for (Object o: o.getList())
for(Object o: getList();)
for(Object o: getList())
for(Object o: o.getList();)
第8题:
private synchronized Object o;
void go() {synchronized() { /* code here */ }
public synchronized void go() { /* code here */ }
private synchronized(this) void go() { /* code here */ }
void go() {synchronized(Object.class) { /* code here */ }
void go() {Object o = new Object();synchronized(o) { /* code here */ }
第9题:
for(Object o : list)
for(Iterator o : list)
for(Object o : list.iterator())
for(Iterator o : list.iterator(); o.hasNext (); )
第10题:
for(char o: list)
for(Object o: getList())
for(Object o: getList();)
for(Object o: o.getList())
第11题:
Just after line 5.
Just after line 6.
Just after line 7.
Just after line 8(that is, as the method returns).
第12题:
for(Object o : list)
for(Iterator o : list)
for(Object o : list.iterator())
for(Iterator o : list.iterator(); o.hasNext (); )
第13题:
1. import java.util.*; 2. class ForInTest { 3. static List list = new ArrayList(); 4. 5. static List getList() { return list; } 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. // insert code here 10. System.out.print(o); 11. } 12. } 第 9 行插入哪一项将输出 abc?()
第14题:
现有: 1. import java.util.*; 2. class ForInTest { 3.static List list - new ArrayList(): 4. 5.static List getList() { return list; } 6. 7.public static void main (Strincj[] args) { 8.list.add("a"); list.add("b"); list.add("c"); 9. //insert code here 10. System.out.print (o); 11. } 12. } 第9行插入哪一项将输出abc?()
第15题:
public class Test { public static void main(String args[]) { class Foo { public int i = 3; } Object o = (Object)new Foo(); Foo foo = (Foo)o; System.out.println(“i = “ + foo.i); } } What is the result?()
第16题:
Which three will compile and run without exception?()
第17题:
3. import java.util.*; 4. class ForInTest { 5. static List list = new ArrayList(); 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. //insert code here 10. System.out.print(o); 11. } 12. } 哪一行插入到第9行将导致输出“abc”?()
第18题:
Just after line 13.
Just after line 14.
Never in this method.
Just after line 15 (that is, as the method returns).
第19题:
Line5
Line6
Line7
Line8
Line9
Line10
第20题:
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
第21题:
i = 3
Compilation fails.
A ClassCastException is thrown at line 6.
A ClassCastException is thrown at line 7.
第22题:
Just after line 5.
Just after line 6.
Just after line 7.
Just after line 8(that is, as the method returns).
第23题:
Just after line 5
Just after line 6
Just after line 7 (that is, as the method returns)
Never in this method.
第24题:
Just after line 5
Just after line 6
Just after line 7 (that is, as the method returns)
Never in this method.