Explain Object Construction in simple terms

In Java, object types (i.e., classes) must be explicitly constructed for initialization. Explain object construction. Then, state the name of the mechanism for object destruction, and explain in simple terms how it works.

Questions by Melll

Showing Answers 1 - 6 of 6 Answers

Priya

  • Mar 15th, 2012
 

We can construct the objects for a class by using the new keyword in java.

Suppose take an Employee class and we can construct the objects for this class in the following way.
Employee emp=new Employee();
Constructing the objects means we are allocating the memory for the object which can be used to access the
instance variables and instance methods of the class.with out allocating the memory we cannot access them.

 
            

  Was this answer useful?  Yes

Priya

  • Mar 16th, 2012
 

In java Object destruction is automatically done by Garbage Collector which is provided y java run time system.

when ever the scope of the object is over then the memory which is allocated for that object is released by the garbage collector.The programmer no need to do anything explicitly.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions