• Post Reply 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JVM

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please explain why no 56 correct and what is the different between this tow answers !!?
merci!
When does the JVM exit?

1-After the main method returns.
2-After all the non demons threads created by the application complete.
3-After all the demon threads created by the application complete
4-When a thread executes System.exit();
5-When an uncaught exception is thrown in a non demon thread.
6-When an uncaught exception is thrown in a demon thread.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In both 5 and 6, there may be other non-demon Threads that are running, so the exception will just be reported and the other Thread(s) will continue.
Bill
 
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill:
If other thread(s) are to continue, then JVM does NOT exit. So can we say 5 and 6 are correct answers?
Barkat
 
zaghal mohd
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
William Brogden As yopu said (there may be other non-demon Threads that are running, so the exception will just be reported and the other Thread(s) will continue.
Bill) does the JVM exit? How (comment)??!
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JVM will ALWAYS exit when someone says "System.exit()" regardless of how many threads (daemon or not) are still alive.
For bonus points, here are a few JVM exit and Garbage Collection (gc) questions for you to think about. They are in the spirit of the exam...
Which of these are true?
1. Once an overridden finalize() method is invoked, there is no way to make the object ineligible for gc
2. All objects that have an overridden finalize() method are guaranteed to have their finalize() called before the JVM shuts down, unless it shuts down because of an error or exception.
3. Objects which have at least one reference referring to them will never be garbage collected.
(in other words, if object 1 has a reference to object 2, then object 2 cannot be garbage collected)
4. Once a finally block is invoked, it will always run to completion.
5.Once a try block is entered, a matching finally block will always be invoked (regardless of the outcome of the try/catch)
have fun.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic