Explain Data Types in Java?

Every  variable  in java  has  a  data type.  Data  type specify the  size of the memory occupied   and  type  of   values  and  that  can be  stored  in a  variable.

Java  language  is  rich in the data type. Consider  the bellow  figure  is specify  the  data type  in java under various categories.

data types2



Integer types:-

Integer types  can hold   numbers such as 123,-95,143, the  size of  the  values  that can be  stored  depends  on  the  integer  data type we  choose.

Java  supports  four  types of integers  they are:

Byte, shot, int & long.

Java doesn’t  support  the  concept  of   oriented  types and  there fore  all java values  one  singed means  they  can be positive (or) negative.

Size  of  integer types.

Byte  - 1 byte

Shot  - 2 bytes

Int      -  4bytes

Long  - 8 bytes


data types1


Floating  point  types:-

Floating point type used to hold  numbers correcting  fractional  parts. Such as

   27.59, 143.143 ,-1.143

There  are  two  ponds  of floating  point storage  in java  as shown below

data types

The float  type  values  are  single precession  numbers and  double type  represent  double precession  numbers

Sizes of  float  type:-

Float - 4 bytes

Double  - 8 bytes

Float  pi =3.142
Double  distance = 1.9803

Character  type :-

 In  order  to store  character  constants  in memory  java  provides  character  data type  called char. The  char  type  resumed  size  of  two  bytes but  basically  it  can  hold  a  single  character.
    
       char  ch= ‘x;

Boolean type :-

 Boolean  type in used  when   we  want  to  test  a  particular condition   during  the execution of  the  program. They are only  two values that  a  Boolean  type  can take  true  (or) false.

Boolean type   are  denoted  by  a  keyboard  Boolean  and  uses   only  one byte of memory.

Class:-

Object  contain  data &  code  to  manipulate  the  data. The  entire  set  of  data  &  code  of  an  object can be  mode by  a  user defined   data type, using the concept  of  class.  A  class  may be a  thought of  a  data type  and  object  &  variable  of  that  data type.  Once  the  class   has been defined  we can create  any number  of  object  belonging to  that  class.  Each  object  is  associated  with  the data  of  type class, with which  they  are created.  A  class  is there  a  collection of  objects  of  similar type.

Interface:-

 An  interface  in  basically  a kind  of class. Like  classes interfaces  contains  methods  and  variables. But with a refer difference , the difference is  that  interfaces define  only abstract methods &  final fiels.

There means that interfaces  don’t  specify  any code  to implement  there  methods and  datatypes contain  only constants.

Arrays:-

An  arrays   are a group  of contagious (or) related  data  items  that share  common  name.

For eg: we can  define an  array name  salary to represent  a set  of  salaries (or) a group of  employees.

A particular   value   are indicated  by writing a number  called index number (or)   subscript  in  brackets  after  the  array  name.

For  eg:-    int salary [10];

Represents  the salary of  11th  employee  while  the   complete  set  of  values  is  referred  to as an  array, the individual   values  are  called   elements. Arrays   can be  of any  variable   type.

Related

Java 7375945326265057505

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item