What are reference data types in Java?

Java 8Object Oriented ProgrammingProgramming

Reference datatypes in java are those which contains reference/address of dynamically created objects. These are not predefined like primitive data types.

Following are the reference types in Java.

  • class types − This reference type points to an object of a class.

  • array types − This reference type points to an array.

  • interface types − This reference type points to an object of a class which implements an interface.

Once we create a variable of these types (i.e. when we create an array or object, class or interface).

  • These variables only store the address of these values.

  • Default value of any reference variable is null.

  • A reference variable can be used to refer any object of the declared type or any compatible type.

Example

Animal animal = new Animal("giraffe");
raja
Published on 12-Feb-2018 15:12:53
Advertisements