solve the quiz on (urgent)

grabage collection

I want the answer for this question ?

question no : 1

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?

A. Just after line 5

B. Just after line 6

C. Just after line 7 (that is, as the method returns)

D. Never in this method.

please send the answers to the above question to my mail id satishmca2005@yahoo.com

question no : 2

Given:

10. public Object m() {

11. Object o = new Float(3.14F);

12. Object [] oa = new Object[1];

13. oa[0] = o;

14. o = null;

15. return oa[0];

16. }

When is the Float object, created in line 11, eligible for garbage collection?

A. Just after line 13.

B. Just after line 14.

C. Never in this method.

D. Just after line 15 (that is, as the method returns).

please send the answers to the above question to my mail id satishmca2005@yahoo.com

question no : 3

1. class Bar { }

1. class Test {

2. Bar doBar() {

3. Bar b = new Bar();

4. return b;

5. }

6. public static void main (String args[]) {

7. Test t = new Test();

8. Bar newBar = t.doBar();

9. System.out.println(搉ewBar?;

10. newBar = new Bar();

11. System.out.println(揻inishing?;

12. }

13. }

At what point is the Bar object, created on line 3, eligible for garbage collection?

A. After line 8.

B. After line 10.

C. After line 4, when doBar() completes.

D. After line 11, when main() completes.

please send the answers to the above question to my mail id satishmca2005@yahoo.com

question no : 4

12. void start() {

13. A a = new A();

14. B b = new B();

15. a.s(b);

16. b = null;

17. a = null;

18. System.out.println(搒tart completed?;

19. }

When is the B object, created in line 14, eligible for garbage collection?

A. After line 16.

B. After line 17.

C. After line 18 (when the methods ends).

D. There is no way to be absolutely certain.

E. The object is NOT eligible for garbage collection.

please send the answers to the above question to my mail id satishmca2005@yahoo.com

question no : 5

1. class TestA {

2. TestB b;

3. TestA() {

4. b = new TestB(this);

5. }

6. }

7. class TestB {

8. TestA a;

9. TestB(TestA a) {

10. this.a = a;

11. }

12. }

13. class TestAll {

14. public static void main (String args[]) {

15. new TestAll().makeThings();

16. // ...code continues on

17. }

18. void makeThings() {

19. TestA test = new TestA();

20. }

21. }

Which two statements are true after line 15, before main completes? (Choose two)

A. Line 15 causes a stack overflow.

B. An exception is thrown at runtime.

C. The object referenced by a is eligible for garbage collection.

D. The object referenced by b is eligible for garbage collection.

E. The object referenced by a is not eligible for garbage collection.

F. The object referenced by b is not eligible for garbage collection.

please send the answers to the above question to my mail id satishmca2005@yahoo.com

Quiz : 2

exception and other doubts

Question no 1 :

Given:

boolean bool = true;

if(bool = false) {

System.out.println("a");

} else if (bool) {

System.out.println("c");

} else if (!bool) {

System.out.println("c");

} else {

System.out.println("d");

}

What is the result?

A. a

B. b

C. c

D. d

E. Compilation fails.

please send the answers to the above question to my mail id satishmca2005@yahoo.com

Question no 2:

class Super {

public int i = 0;

public Super(String text) {

i = 1;

}

}

public class Sub extends Super {

public Sub(String text) {

i = 2;

}

public static void main(String args[]) {

Sub sub = new Sub("Hello");

System.out.println(sub.i);

}

}

What is the result?

A. 0

B. 1

C. 2

D. Compilation fails.

please send the answers to the above question to my mail id satishmca2005@yahoo.com

Question no 3 :

Given:

try {

int x = 0;

int y = 5 / x;

} catch (Exception e) {

System.out.println("Exception");

} catch (ArithmeticException ae) {

System.out.println("Arithmetic Exception");

}

System.out.println("finished");

What is the result?

A. finished

B. Exception

C. Compilation fails.

D. Arithmetic Exception

please send the answers to the above question to my mail id satishmca2005@yahoo.com

Question no 4 :

public class SyncTest{

public static void main(String[] args) {

final StringBuffer s1= new StringBuffer();

final StringBuffer s2= new StringBuffer();

new Thread () {

public void run() {

synchronized(s1) {

s2.append("A");

synchronized(s2) {

s2.append("B");

System.out.print(s1);

System.out.print(s2);

}

}

}

}.start();

new Thread() {

public void run() {

synchronized(s2) {

s2.append("C");

synchronized(s1) {

s1.append("D");

System.out.print(s2);

System.out.print(s1);

}

}

}

}.start();

}

}

Which two statements are true? (Choose Two)

A. The program prints "ABBCAD"

B. The program prints "CDDACB"

C. The program prints "ADCBADBC"

D. The output is a non-deterministic point because of a possible deadlock condition.

E. The output is dependent on the threading model of the system the program is

running on.

please send the answers to the above question to my mail id satishmca2005@yahoo.com

[6225 byte] By [satishmcaa] at [2007-9-23]
# 1
Stop spamming and do your assignment yourself. http://forum.java.sun.com/thread.jspa?threadID=639847
EllaOfTheCindersa at 2007-7-11 > top of java,Core,Core APIs...
# 2
oo!oo! oo!oo!quiz 1A, A, A, A, Aquiz 2B, B, B, BI hope I get these right.
st.murphya at 2007-7-11 > top of java,Core,Core APIs...