File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

overLoading

 
rani nal
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between reference type and object type.
 
Ivan Ivanic
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic