What are the primitive types in Java

Showing Answers 1 - 26 of 26 Answers

joadavis

  • Jun 3rd, 2005
 

According to Java in a Nutshell, 5th ed 
boolean, byte, char, short, long float, double, int

  Was this answer useful?  Yes

shanmukharao

  • Apr 21st, 2007
 

According to their memory allocation order:
byte
short
int
long
float
double
boolean
char

  Was this answer useful?  Yes

manishatlko

  • May 18th, 2007
 


Type                  Size            Value
__________________________
boolean            1 bit            true/false
char                  2 Bytes       Unicode (Extended ASCII)
byte                  1 Byte        
short                 2 Bytes
int                     4 Bytes
long                  8 Bytes
float                  4 Bytes
double              8 Bytes

Unlike C/C++ in java boolean value can not hold in t values 0/1 representing true or false.

All the other primitive types are convertable to each other except boolean, i.e., we cant transform a variable of other data type to boolean and vice versa but other types can be transformed either by implicit or explicit means.

  Was this answer useful?  Yes

There are 8 primitive types in java

int     :     byte  ------>   1 byte   ------>   8 bits
               short ------>   2 bytes   ------>   16 bits
               int     ------>   4 bytes    ------>   32 bits
               long ----->  8 bytes   ------->  64 bits

float :     float  ------->   4 bytes   -------->  32 bits
               double ----->  8 bytes   ------->  64 bits
                  
char :      char  -------> 2 byte    ---------> 16 bits   Note : c,c++ has 1 byte only. because, java has one feature i.e., UNICODE , it's use for internationlization(used to different languages in java like Eng,french,germeny etc.,).

  Was this answer useful?  Yes

Balaji

  • Jun 23rd, 2007
 

Primitive datatypes are given by Java developers as some standard abstraction to store various data items among them are
byte to store one byte numbers
boolean to store two values true-1 anf false-0
char - to store 1 byte characters
short -for storing  2 bytes integer
int for storing 4 bytes integer numbers
long for storing 8 bytes of integer numbers
float to store 4 bytes floating pont numbers along with two digits precesion
double to store 8 byte floating point numbers along with 6 digits precesion

  Was this answer useful?  Yes

Bhavya

  • Aug 2nd, 2007
 

Java has all together 8 Primitive DataTypes:

char taking 2 bytes having its own class Character
byte taking 1 bytes having its own class Byte
boolean taking 1 bytes having its own class Boolean
short taking 2 bytes having its own class Short
int taking 4 bytes having its own class Integer
long taking 8 bytes having its own class Long
float taking 4 bytes having its own class Float
bouble taking 2 bytes having its own class Double

  Was this answer useful?  Yes

teju

  • Nov 5th, 2007
 

Primitive type means .int char double float string single long .............

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions