Hi, I'm just a little confused as to what to we call a reference.

A ob=new B();

Here B is a subclass of A. Should we say "ob is a reference of A which has been assigned an object of B" or "ob is a variable of A which has been assigned a reference of B" ?

When we are assigning an object to a variable (by new()) (Like to ob, in the above code), we're actually assigning the reference of the area allocated by new, to the variable ob. So, how can u call ob a reference even before its assigned an object's reference. Like

A ob;

Even here, will we call ob as a reference of A?

ob is a reference to an object of class A.
It can also hold a reference to an object of any sub-class of A, because any such object is, by definition, a kind of A.
new X() creates an object of class X and returns a reference to that object.
If you define a reference variable but do not assign any value to it, its value will be the special value "null"

Experienced Java programmers tend to talk about an "object" when they really mean "reference to an object", which can be very confusiong for beginners.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.