Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JVM" Watch "JVM" New topic
Author

JVM

zaghal mohd
Ranch Hand

Joined: Jun 27, 2002
Posts: 43
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.


SCJP,SCWCD,CCNA,CCAI,MCP,MCSA,MCSE<br />working on CCNP+SCBCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
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
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
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

Joined: Jun 27, 2002
Posts: 43
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)??!
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
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.


Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0596007124/ref=jranch-20" target="_blank" rel="nofollow">"Head First Design Patterns"</a><br /> <br />Just a Jini girl living in a J2EE world.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM
 
Similar Threads
JVM
Which is right?
When does the JVM exit
JVM
When does the JVM Exit?