Since objects are big, complicated, and vary in size you do not automatically get an object when you declare an object reference variable. For example, in the declaration:
String str;
the variable str
does not actually contain the object, but contains information about where the object is. An object reference is information on how to find a particular object. The object is a portion of main memory; a reference to the object serves as a way to get to that portion of memory.
Here is a tiny program that declares a reference variable and then creates the object:
public class StrRefExample
{
public static void main (String[] args)
{
String str;
str = new String("example string");
System.out.println(str);
}
}
An object contains data and methods (attributes and behaviors). You can visualize the String object in the above program like this:

The data section of the object contains the characters. The methods section of the object contains many methods.
Objects are created while a program is running. Each object has a unique object reference, which is used to find it. When an object reference is assigned to a variable, then that variable says how to find that object.