Uma maneira de simular é diminuindo a quantidade de memória Heap da JVM e
fazer um loop
jogando objetos para a memória!!!


Mas a resposta correta é a E , porque quando ocorre um erro desses e não há
um cath de Error,
para tratalo, o método que executa este código não continua a execução!!!



----- Original Message -----
From: "Caetano" <[EMAIL PROTECTED]>
To: "Java List" <[EMAIL PROTECTED]>
Sent: Wednesday, January 29, 2003 1:46 PM
Subject: [java-list] Dúvida sobre Exceptions


> Olá Pessoal,
>
> Estudando um pouco de exceções, me deparei com uma questão que não soube
> responder, até porque não consigo simular ela:
> Acredito que a(s) possíveis respostas sejam as letras E e F. Conto com a
> ajuda de vocês.
>
> 8. Consider the following class hierarchy and code fragment:
>
> java.lang.Throwable --> java.lang.Error --> java.lang.OutOfMemoryError
>               |
>               |
>               --> java.lang.Exception --> java.io.IOException
>                                                        |
>                                                        |
>                                                        -->
> java.net.MalformedURLException
>                                                        |
>                                                        |
>                                                        -->
> java.io.StreamCorruptedException
>
>  1. try {
>  2.     // assume s is previously defined
>  3.     URL u = new URL(s);
>  4.     // in is an ObjectInputStream
>  5.     Object o = in.readObject();
>  6.     System.out.println("Success");
>  7. }
>  8. catch (MalformedURLException e) {
>  9.     System.out.println("Bad URL");
> 10. }
> 11. catch (StreamCorruptedException e) {
> 12.    System.out.println("Bad file contents");
> 13. }
> 14. catch (Exception e) {
> 15.    System.out.println("General exception");
> 16. }
> 17. finally {
> 18.    System.out.println("Doing finally part");
> 19. }
> 20. System.out.println("Carrying on");
>
> What lines are output if the method at line 5 throws an OutOfMemoryError?
>
> A. Success
> B. Bad URL
> C. Bad file contents
> D. General exception
> E. Doing finally part
> F. Carrying on.
>
>
> ------------------------------ LISTA SOUJAVA ----------------------------
> http://www.soujava.org.br  -  Sociedade de Usuários Java da Sucesu-SP
> dúvidas mais comuns: http://www.soujava.org.br/faq.htm
> regras da lista: http://www.soujava.org.br/regras.htm
> historico: http://www.mail-archive.com/java-list%40soujava.org.br
> para sair da lista: envie email para [EMAIL PROTECTED]
> -------------------------------------------------------------------------
>


------------------------------ LISTA SOUJAVA ---------------------------- 
http://www.soujava.org.br  -  Sociedade de Usuários Java da Sucesu-SP 
dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
historico: http://www.mail-archive.com/java-list%40soujava.org.br
para sair da lista: envie email para [EMAIL PROTECTED] 
-------------------------------------------------------------------------

Responder a