*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes refrence,instance and object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "refrence,instance and object" Watch "refrence,instance and object" New topic
Author

refrence,instance and object

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Dear sir i often get confuse the diffrence between refrence,instance and object of a class so please specify the difrence between these things.


with regfard


Arun kumar maalik
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Hi

My name is not sir but i will reply

When a class is instantiated and loaded it becomes an object.

When you have many objects of the same type they can be called as instances of that object. They need not have the same data in them.

A reference is used to point to an object. This reference may also point to null which means that it points to nothing. A reference is a way by which you can access the contents of that object. If you try to execute methods or access variables of a reference that points to null, you get a NullPointerException.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
Don't get me started about those stupid light bulbs.
 
subject: refrence,instance and object