Wednesday, 23 May 2018

DATA TYPE IN JAVA

DATA TYPE:

Different data type allow you to select the type appropriate to the needs of the application Data type in java are classified into two types:Different type of Data types for different type of value

PRIMITIVE DATA TYPES-

1)-Integer 

Integer types can hold whole number such as 345 and -3435.The size of the values that values that can be stored depends on the integer type that we choose.

Type                  Size                   Default value          Range of values that can be 
                                                                                        stored               
 byte                  1 byte                            0                    -128 to 127

short                  2 byte                            0                     -32768 to 32767

int                      4 bytes                          0                     -2,147,483,648 to
                                                                                         2,147,483,647

long                    8 bytes                         0L                     9,223,372,036,854,775,808 to                                                                                                                   9,223,372,036,854,775,807

2)-Floating point:
Floating point data types are used to represent numbers with a fractional part.Single precision floating point number occupy 4 bytes and Double precision floating point number occupy 8 bytes.There are two subtypes:
Type                  Size                 Default value            Range of values that 
                                                                                         can be stored       
 float                  4 byte                     0.0f                      -3.4e-038 to 3.4e+038
                                                                                                         
double              8 byte                       0.0d                        1.7e-308 to 1.7e+038 

3)Character
It stored character constants in the memory.It assumes a size of 2 bytes,but basically it can hold only a single character because char stores unicode character sets.It has a minimum value of 'u0000'
and a maximum value of 'uffff' 

 Type                  Size                      Default value                    
 char                  2 byte                         '\u00000'                                     
                                                                                                         
String                  null                         2147483647(2pow(31)-1)

4)-Boolean
Identifiers are name provided by you.These can be assigned
to variables,method,functions,classes etc.
BOOLEAN IN THE FORM OF TRUE AND FALSE 


No comments:

Post a Comment