Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

roundup question errors

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Answer to the question #127 says that if(b=true) is a valid statement. It goes on saying that b will be assigned to the value true...
Answer to the question #132 says that if finally clause is executed, remaining statments in the current method will be skipped...Well, only the remaining statements in the try block would be skipped, not the whole method...
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
For #127, the text is correct as is. Try compiling and running it - you'll see.
For #132, the text is: "If an exception is not caught, the finally block will run and the rest of the method is skipped." This is also correct. Perhaps it is not clear that "if an exception is not caught" means "if there is an exception thrown which is not caught" rather than "if no exception is caught(possibly because none was thrown)". In the former case - if an exception is thrown and not caught - then the only thing in the method that will still execute is the finally clause. Again, try it.
 
Murat Gungor
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for the reply Jim,
On the first one, I didn't realize that the if statement was evaluating the outcome of the expression, rather than operating on an invalid comparison - which would be caught by the compiler...
On the second one, I didn't assume that an exception was thrown - hence your suggestion of re-wording the question...
Regards, :roll:
 
Murat Gungor
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator

In the former case - if an exception is thrown and not caught - then the only thing in the method that will still execute is the finally clause. Again, try it.


If the try block where the exception is thrown is wrapped with another try block, then the rest of the code in the method after the outer try block will not be skipped...
 
Let me tell you a story about a man named Jed. He made this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!