Posts

Showing posts from April, 2018

Data Types in Java

Image
In Java, every variable and every expression has some type. Data type defines the values that a variable can take. Data types represent the different values to be stored in the variable. Each and every data type is clearly defined. Every assignment should be checked by compiler for type compatibility. Because of above reasons, we can conclude java language is strongly typed programming language. Java is not considered as pure Object Oriented Programming language because several OOPs features are not satisfied by Java like (Operator overloading, Multiple Inheritance etc..). Moreover, we are depending on primitive data types which are non-objects. Data Type Default Value Default size byte 0 1 byte short 0 2 bytes int 0 4 bytes long 0L 8 bytes float 0.0f 4 bytes double 0.0d 8 bytes boolean false 1 bit char '\u0000' 2 bytes 1) Primitive data types In Java, we have eight primitive data types: boolean, char, byte, short, int, long, float and double. Ja