Tuesday, December 13, 2011

What is a data type?

Data Type: The data type of a programming element refers to what kind of data it can hold and how the data is stored. If we take integer data type, it can hold only integer values. In the same way, String data type can hold only string values.  Data types are divided into two types.

1. Primitive data types
2. Reference data types

1.Primitive data types: Primitive data types are predefined data types. Always they hold only one type of data. Suppose if a variable is declared as integer, It can hold only integer values.Following are the examples of primitive data types.
Example:
int
String
float
double
char
boolean
byte
short

2. Reference data types: The reference data type is a variable that can contain the reference or an address of dynamically created object. This data type is not predefined.

Example:
Array
class
interface