Share on Google+Share on Google+

naveen
Reference type Vs Object type.
2 Answer(s)      8 years ago
Posted in : Java Beginners

Ads

View Answers

October 17, 2008 at 6:04 PM


Hi friend,


Objects :

Objects are the basic unit of object orientation with behavior, identity.
These are part of a class but are not the same. An object is expressed by the variable and methods within the objects.
These variables and methods are distinguished from each other as instant variables, instant methods and
class variable and class methods.

* All objects are allocated on the heap.
* Objects consist of instance fields for the class of the object, plus instance fields for its superclasses.
* Every object is created by a class constructor. Interfaces don't have constructors.


Reference variables :

* All non-primitive variables contain only references to objects on the heap.
They never contain the object. C++ object variables may be either,
but Java supports only object references.

For Example :

Book bookvar = new Book("Java");


bookvar is not an object, it's a variable which contains a reference to an object.
Objects don't have names, just types and locations in memory (and, of course,
fields and methods).

Create a new Book object in memory.
Initialize it with the data sent as arguments to a constructor.
When created, assign a reference to that object to the Book variable bookvar.
"bookvar" is a reference or object type variable which may reference a Book object or
an object of any subclass of Book.


For more information on

http://www.roseindia.net/java/beginners/oop-in-java.shtml

http://www.roseindia.net/java/java-tips/oop/oop-summary.shtml


Thanks


March 25, 2010 at 10:15 PM


Long story short, for this below field declaration:

Employee mgr = new Manager(); // lets assume Manager is a subclass of Employee

Class 'Employee' would be the REFERENCE TYPE
and
Class 'Manager' would the OBJECT TYPE

Moderators, please correct me if I'm wrong.









Related Tutorials/Questions & Answers:
Reference type Vs Object type. - Java Beginners
Reference type Vs Object type.  Can anyone explain the exact difference between Reference and Object, how can i create a reference ? When exactly... or object type variable which may reference a Book object or an object of any
object retun type - Java Beginners
object retun type  Hi, i have to create a method which should have return type of object . The object should contain 'list of filenames' array and a boolean field 'isVal'. Can anybody help
Advertisements
Method is undefined for the type Object(org.apache.jasper.JasperException)
Method is undefined for the type Object(org.apache.jasper.JasperException)  [Tag:java] I am getting an Error, while accessing a JSP Page through my... getPracticeRevenueCode() is undefined for the type Object
Does the object type known during compilation in Java?.
Does the object type known during compilation in Java?.  class A { } class B extends class A { } class checkType { public static void main(String[] args) { A ObjA = new B();/// Here ObjA is of type A--> this fact
Convert an Integer type object to a String object
Convert an Integer type object to a String object   ... the Integer type object to a String object using the Integer.toBinaryString...; Create a class "NumberFormats" where an integer type object is converted
Object reference not set to an instance of an object
Object reference not set to an instance of an object  Object reference not set to an instance of an object
type casting
List (object type) <Object> totalList(int pi){ try{ Query q...type casting  <--bean class-->method calllist is of object type...){ return null; } how to type cast object type to entity type
I retrieve a String or other object type without creating a new object each time.
I retrieve a String or other object type without creating a new object each time.  How can I retrieve a String or other object type without creating a new object each time
type casting
type casting  what is type casting
Type casting
Type casting  how to type cast a string value to byte array
PHP Object Type
PHP Object: Class, and Object are one of the most important feature of OOP. Object is the instance of a class, to create an object we use new keyword. In PHP we can convert any value to an object of a predefined class called stdClass
type mismatch
type mismatch  Statement s= con.createStatement(); this line gives error of "type mismatch" I am using eclips nd new to servlet nd JDBC, Please help me, Thank you
type casting
type casting  int n=20; n=sizeof((char)(float)n); what is n value
data type
data type  which data type is used to store video file in mysql databse
data type
Single Double Decimal Char Boolean Date String Object
Casting (Type Conversion)
casting. In java one object reference can be type cast into another object reference... reference to a reference variable of the type Object, as Object class comes at the top... Casting (Type Conversion)      
Java type casting
Java type casting  Can a Byte object be cast to a double value
Type casting in java
of casting; primitive type and reference type casting. Reference type casting is nothing but  casting one object type to another object type. In simple... a double type cast to int type    Reference type casting : In java type
PHP Type Hinting
a value into objects of a class or to an array. Type Hints only supports object... object of any class type or array type. Example : <?php class One...PHP Type Hinting Function: Type hinting is a special type of function which
Type Comparison Operator
an object to a specified class type. The instanceof operator is defined..., if the object or array is an instance of the specified type; otherwise it returns... the object of class "X" has the reference to the object of class "Z"
PHP Object Reference
that the terms object and reference is interchangeable. Now we must know what is actually an object and what is a reference. Whenever an object is instantiated... we call the first reference of that memory chunk as object and the objects
UIButton sender type cast
UIButton sender type cast  Hi, I want to type cast sender object... to typecast the sender object into UIButton. Please see the following code: UIButton... to typecast the sender object into UIButton. Please see the following code: UIButton
coding for re-type password
coding for re-type password  coding for re-type password
Document Type Definition
Document Type Definition  What is Document Type Definition
fastest type of JDBC driver
fastest type of JDBC driver  What is the fastest type of JDBC driver
Fastest type of JDBC Driver
Fastest type of JDBC Driver  hello, What is the fastest type of JDBC driver?   hii, Type 4 is the fastest JDBC driver
Java type casting
Java type casting  What is Downcasting
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
What is mime type in HTML
What is mime type in HTML  what is mime type in html? is it different in new HTML5
What is mime type in HTML
What is mime type in HTML  what is mime type in html? is it different in new HTML5
type casting purpose
type casting purpose  what is type casting , could u explain with practical example
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads