aspose file tools
The moose likes Beginning Java and the fly likes constructor and exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "constructor and exception" Watch "constructor and exception" New topic
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]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: constructor and exception
 
Similar Threads
TransientWriter
Constructor Exception
Can we write constructor for Servlets?
Constructors:True or false
Dan's mock question