Question :Describe what happens when an object is created in Java? (CoreJava)
Answer :Several things happen in a particular order to ensure the object is
constructed properly:
1. Memory is allocated from heap to hold all instance variables and
implementation-specific data of the object and its superclasses.
Implemenation-specific data includes pointers to class and method data.
2. The instance variables of the objects are initialized to their default
values.
3. The constructor for the most derived class is invoked. The first thing a
constructor does is call the consctructor for its superclasses. This process
continues until the constrcutor for java.lang.Object is called, as
java.lang.Object is the base class for all objects in java.
4. Before the body of the constructor is executed, all instance variable
initializers and initialization blocks are executed. Then the body of the
constructor is executed. Thus, the constructor for the base class completes
first and constructor for the most derived class completes last.
www.interviewhelper.org is a hope for all the Job seekers. Users can find unlimited here. These range from technical to HR, from functional to behavioral. www.interviewhelper.org contains in the fields like Ajax,VB,Networking,Sharepoint,JEE,Perl,Javascript,Bioinformatics,Classic ASP,Unix,Linux,Accounting,Oracle DBA,Microprocessor,Bluetooth,jms,jme,.net framework,ABAP,ASP,ASP.net,Basic .net Framework,Interview Questions,C language,C++,database,Oracle,Java,PHP,LAMP,SAP etc.
Thursday, March 12, 2009
Describe what happens when an object is created in Java? (CoreJava)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment