*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Difference between Instance, Object and reference 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 "Difference between Instance, Object and reference" Watch "Difference between Instance, Object and reference" New topic
Author

Difference between Instance, Object and reference

Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
Can someone please let us know what is the difference between object, instance and reference?


Mission SCWCD. Mission SCJP Complete: SCJP 1.4 - 91%
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
Naina Si
Ranch Hand

Joined: Nov 05, 2003
Posts: 134
Object is an instance of a Class. You can create many instances of a class (Objects of that particular Class type)

You can refer to objects using references.
Karun Subramanian
Greenhorn

Joined: Aug 10, 2006
Posts: 3
Hi !

Object = Instance of a Class.
Instance = Object
Reference = A variable that holds bit patern which points to the Object in the Memory (Heap).

Example:

public class Car {
int year;
String make;
public static void main(String[] args) {
Car mycar = new Car(); // Create a Car object.
// Here mycar = Reference variable that points to the Object of type Car
}
}
 
wood burning stoves
 
subject: Difference between Instance, Object and reference
 
Similar Threads
refrence instance and object ?
instance/reference
Related to Object
object Vs instance
Diff between object,instance,refernce variable