José,

Não há maneira de saber exatamente quando os objetos serão coletados pelo "garbage collector" uma vez que você não pode chamar diretamente pelo garbage colector, ele funciona automaticamente, você pode no máximo SUGERIR a partir de um método que o garbage colector seja acionado, logo, a resposta neste caso é D.

Veja por exemplo a descrição do método System.gc() da API da JDK 1.4

Runs the garbage collector.

Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.

[]s

Carlos


jose soares sobrinho wrote:
[EMAIL PROTECTED]">

Olá lista

estudando para certificação e; podes , de forma didática, responder-me esta questão? Portuguese please ;)

Here is a method that creates a number of String objects

in the course of printing a countdown sequence:

1. public void countDown()

Estou 

2. for( int i = 10 ; i >= 0 ; i-- ){

3. String tmp = Integer.toString( i );

4. System.out.println( tmp );

5. }

6. System.gc()

7. System.out.println( BOOM! );

8. }

When the program reaches line 7, how many of the

String objects created in line 3 will have been garbage

collected? Assume that the System.out object is not keeping

a reference.

RESPOSTA

a - nome

b - 11

c - 10

d - there is no way to tell



    ))    []s, Soares      http.vivavida!com
C|~~|
.`--'  http.macrosoft.tbm



Yahoo! Encontros
O lugar certo para você encontrar aquela pessoa que falta na sua vida. Cadastre-se hoje mesmo!

-- 
/**
 * [Carlos H.] - [EMAIL PROTECTED]
 * Núcleo de Informática UNERJ - Centro Universitário de Jaraguá do Sul
 * 
 * Não use drogas, use Linux!
 */



Responder a