Java Data-types:

In Java every variable, expression has a type and all assignments are checked by compiler for type compatibility. Therefore java is treated as strongly typed language
Except boolean and char the remaining datatypes are considered as signed datatypes.


1.       byte: Range from -128 to 127
+ve numbers are represented directly in memory, -ve are represented as 2s compliment.
Example:
1.       byte b=10
2.       byte b=130 compile time error. Possible loss of precision required byte found int

2.       short: Range from -32768 to 32767
3.       integer:
Example
int x=0;
if (x)
{
        Sopln(“Hello”);
}
Else
{
        Sopln(“Hi”);
}
Compile time error: incompatible types found: int required: boolean
4.       char literal :
Example:
char ch=’a’;   correct
char ch=a; compile time error
char ch=’ab’; unclosed character literal
char ch=”ab”; incompatible types