Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

object instantiation VS initialization  RSS feed

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
What happens first (i) object intialization OR (ii) object instantiation
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
object instantiation involves allocating memory for the new instance to exist,

object initialization involves setting the values of the new instance to an initial state (via calls to the constructors)



which do you think occurs first?
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How could you possibly initialize an object that didn't exist?

Where did this question come from - another interview question?

If you want to get picky, in one of the first steps in object instantiation the JVM sets the allocated memory to zero so initialization starts then.

Bill
 
Sheriff
Posts: 21288
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an intermediate question
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!