Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

overLoading

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between reference type and object type.
 
Ranch Hand
Posts: 100
  • 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.
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this JavaRanch Campfire story: Cup Size -- a story about variables
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • 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.
 
Greenhorn
Posts: 27
  • 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.
 
This is awkward. I've grown a second evil head. I'm going to need a machete and a tiny ad ...
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!