| Author |
constructor and exception
|
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Hi, Is the memory for an object allocated before or after the constructor is called ? If before what will happen when the constructor throws an exception.
|
Groovy
|
 |
Shashi Kanta
Ranch Hand
Joined: May 08, 2002
Posts: 89
|
|
memory for an object is allocated as soon as its instantiated. when the constructer is invoked initialization takes place for the variables used, and methods may be invoked as needed. if there is an exception thrown in the constructer, the program terminates and the grabage collector will later reclaim the memory assigned for the object.
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
Further information can be found in The Life Cycle of an Object Section of Sun's Java Tutorial. The section on Creating Objects is particularly relevant.
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: constructor and exception
|
|
|