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

"new" keyword  RSS feed

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wht happens when we instantiate an object using "new" keyword (in heap,reference,constructor)?
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
in my opinion, when the new keyword is invoked, this mean you are creating an object and assigning a variable to reference on that object. Of course that object will eat up space in the computers memory like any other variable(primitives). Whenever you want to use that object, you can use the reference variable. When an object is instantiated, of course the constructor is inspected and initialize the objects attributes. This enforces consistency on creating objects.
Hope that helps..
Cyrus
[ November 18, 2003: Message edited by: Cyrus Serrano ]
 
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eswar,
In my opinion, there is a very good explanation of this in Bruce Eckel's book, Thinking in Java. If you haven't already looked at it, allow me to (highly) recommend it!
Good Luck,
Avi.
[ November 18, 2003: Message edited by: Avi Abrami ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!