wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes overLoading 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 "overLoading" Watch "overLoading" New topic


rani nal

Joined: Apr 21, 2008
Posts: 1
what is the difference between reference type and object type.
Ivan Ivanic
Ranch Hand

Joined: Oct 31, 2007
Posts: 100

Left side will determine reference type, and right side will determine object type.
So in this case you have Animal reference to object of type Dog.

in this case you have Animal reference to object of type Animal.

and here you have Dog reference to object of type Dog.

<a href="http://faq.javaranch.com/java/UseRealWords" target="_blank" rel="nofollow">Use Real Words</a> <a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">!!!Use Code Tags!!!</a> <a href="http://faq.javaranch.com/java/SayThanks" target="_blank" rel="nofollow">Say Thanks</a><br />scjp6
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Yggdrasill, your name doesn't confirm to the JavaRanch's naming policy..
Precisely it should be a combination of your first name and last name separated by spaces. Please chnge it by following this link.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

See this JavaRanch Campfire story: Cup Size -- a story about variables

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Rani Nal,
Welcome to Javaranch.

A reference to an object is simply some fixed-size value that refers to the object in some way. It is the left hand side of an assignment.

In the preceding line the refrence type is Animal(which in itself is also a class/interface). Now, you can assign any subtype to a parent refrence type.

The object type on the other hand is the actual object that the refrence points to or holds. e.g. in preceding code the object type is of Dog.

Well, at compile time you can assign any subclass object type to supertype refrence. The actual capabilities of the object are checked at runtime.

Hope that helps.
venu jayaram

Joined: Mar 11, 2008
Posts: 27

the refrence type will create on stack, but object type will create on heap.
I agree. Here's the link: http://aspose.com/file-tools
subject: overLoading
It's not a secret anymore!