File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Another question from javacross simulation! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Another question from javacross simulation!" Watch "Another question from javacross simulation!" New topic

Another question from javacross simulation!

Noel Hinders
Ranch Hand

Joined: Jan 13, 2001
Posts: 44
Hi all,
here is a question from simulation please help me for a solution.
Q].You are updating some data and is result of some calculations. When your thread performs an integer division by 0 causing an ArithmeticException, you have no catch code, which of these will happen
a].the application will terminate
b].the JVM will start a new thread to perform the update operation
c].the application will not terminate but the updating will cease
d].none of the above will happen
Arunagiri, Shanmugham
Ranch Hand

Joined: Jan 23, 2001
Posts: 46
I think the application will terminate and a stack trace will be printed on the screen.
SeE Consulting(P) Ltd

Sun Certified Programmer for Java2 Platform
Anshuman Acharya
Ranch Hand

Joined: Jan 19, 2001
Posts: 144
I agree, anuragiri
Junaid Bhatra
Ranch Hand

Joined: Jun 27, 2000
Posts: 213
Your application may or may not terminate. Whenever there is an uncaught exception in a thread, that thread dies. Ofcourse if your program has only 1 non-daemon thread, i.e. user-thread (for eg. only a main thread), then JVM will exit. Otherwise if there are multiple daemon threads running, then the other threads will happily continue to run and JVM will not exit.
anil bisht
Ranch Hand

Joined: Nov 04, 2000
Posts: 81
i agree with u Junaid
Noel try this code and u will get the answer
public class A extends Thread{
static int i=0;
public void run()
System.out.println("all done before"+i);
if (i ==0)
i = 1/i;
System.out.println("all done"+i);
public static void main(String[] args){
A t1 = new A();
sleep(200);}catch (Exception e){}
A t2 = new A();
System.out.println("all done. exiting now");

I agree. Here's the link:
subject: Another question from javacross simulation!
It's not a secret anymore!