Ads Sponsored By Google :)

Friday 25 January 2013

data types used in java with size and range example|of primitive|non primitive|user defined|reference|abstract|Char|double|long|byte|boolean what|are explain|different


data types in java primitive data types in java non primitive data types in java reference data types in java
data types in java with size data types used in java with size and range primitive data types used in java
user defined data types in java abstract data types in java explain different data types in java with examples
different data types in java data types used in java abstract data types in java with examples
long data type in java example byte data type in java example boolean data type in java example
char data type in java example double data type in java example user defined data types in java with example example of abstract data types in java what are abstract data types in java

   Data Types:

     Data types are used for allocating sufficient amount of memory for input of the program
  in the main memory of the computer by allocating sufficient amount of memory space either 
  by following static memory allocation or by following dynamic memory allocation.

Data Types in java


    In general the most of the programming language datatypes are classified into 3 types 
  they are.

   1) Fundamental Data Type/Primitive Data type 
   2) Derived Data Type
   3) User/Programmer/Refrence defined Data Type.

a)     Fundamental Data Type/Primitive Data Type:

       Fundamental data type are those which are developed by language developers and 
   whose variables allows us to take only one value but they never allows us to take multiple   
   values of same type.

    For Example:

     int a=10;        //valid
     int 1=10,120,1300; //invalid

b)     Derived DataType:

      Derived data types are those whose variables allows us to take multiple values of same \
   type but they never allows to take multiple values of different type.

   For Example:

     int a[]={10,20,30};//Valid
    int b[]={10,10.75,A};//Invalid

c)     User Defined /Reference Data Type:

        User Defined Data Type are those which are developed by programmer by using
  language facilities and whose variables  allows to take multiple values of same type or 
 different type or Both.

  For Example:

  In java to develop of our own user defined data type we use classes concept (class and Interfaces concept).

  Fundamental data types:
     Java fundamental data types are classified into 8 types and they are categorized into  4 
   categories they are

   1)Integer Data Type
   2)Float Data Type
   3)Character Data Type
   4)Boolean Data Type

A) Integer Data Type:
     Integer Category data type are used for storing the integer data in the main memory of the 
   computer by allocating sufficient amount of memory space . Integer category data types are 
   of 4 types and they are

       DataType          Size (In Bytes)                           
         a)byte                   1
         b)short                 2
         c)int                      4
         d)long                   8


 By choosing any language category datatype context multiple data types then choosing an appropriate datatype is one of the important factor by knowing its range.

  B) Float Data Type:
  
     Float Data type is used to store real constant values in the main memory of computer by allocating sufficient amount of memory space.


                      DataType          Size                           
                       a)Float            4bytes
                       
                       b)Double         8 bytes


     For float data type it takes 4 bytes for memory space. whenever we store  a real constant value in variable of float datatype then the real constant value stored int the main memeory in such way that after the .(dot) it takes “7” decimal places and such values much be followed by letter “f”

   For Example:

   Float f=10.75f;

    For double data type it will store in main memory in such that after .(dot) it takes 15 decimals.

   For Example:

    Double d=10.75;

  C)  Character Data Type:

          A Character is an identifier which is enclosed with in single quotes 

          For Example:
                     ‘A’,’#’,’$’etc………

   String:
             String is collection/sequence of characters enclosed in double quotes.

      For Example;
                      “OurJavaWorld”

   D) Boolean Data Type:

   1) Boolean datatype is to store logical values i.e true and false.
   2) Boolean data type takes Zero bytes of main memory space because Boolean data type 
       implemented    with with a general purpose register called flip flop

     For Example:
          
          Boolean a=true;
          Boolean b=false;
    

No comments:

Post a Comment

LinkWithin