Class 4
Class 4
___________________
Keywords in Java:
-------------------------
-> Keywords are the reserved words in java
-> We can only use the keywords, we can't able to perform any modification over the
keywords
Object keywords:
--------------------------
-> new, null
boolean:
--------------
-> We can store true or false values in the boolean
-> eg:
boolean bool = true;
boolean bool = false;
byte:
---------
-> The size of byte is 1 byte or 8 bits
-> The range is -128 to 127
-> eg:
byte b = 10;
byte b2 = b;
byte b3 = 10+1;
byte b4 = 10+b; -------------------------------------> c.e
Reason: While performing this kind of operations the data type will be
converted into int. We can't store int data type in byte because the size of byte
is 1 byte and size of int is 4 byte.
short:
----------
-> The size of short data type is 2 bytes
-> The range is -32768 to 32767
-> eg:
byte b = 10;
short s = b+1; -----------------------------> c.e
short s1 = 100000; ----------------------> c.e
short s2 = 11+12/2;
int:
------
-> The size of int is 4 byte
-> The range is -2147483648 to 2147483647
-> eg:
byte b = 10;
short s = b+1;
char ch = 'a';
int a = b+s+ch;
int a2 = 10b; -----------------> c.e
long:
--------
-> The size of long is 8 bytes
-> It can store upto 15 to 16 digit values
-> eg:
byte b= 10;
short s = b+1;
char ch = 'a';
int a = b+s+ch;
long l = a+b+s+ch;
long l1 = 10L;
long l2 = 10l;
long l3 = 10.0f; ------------> c.e
long l4 = 10.0d; -----------> c.e
long l5 = 77756489988; -----------> c.e
long l6 = 77756489988L;
float:
---------
-> The size of float is 4 byte
-> The range of float is upto 6 to 7 decimal precision values are allowed
-> eg:
byte b= 10;
short s = b+1;
char ch = 'a';
int a = b+s+ch;
long l = a+b+s+ch;
float f = b+s+ch+a+l;
float f1 = 10.0;
float f2 = 10.0f;
float f3 = 10.0F;
double:
-------------
-> The size of double is 8 byte
-> It can have the precision of upto 12 to 15 range of decimal values
-> Except boolean it allows all the other data type to store
-> eg:
byte b= 10;
short s = b+1;
char ch = 'a';
int a = b+s+ch;
long l = a+b+s+ch;
float f = b+s+ch+a+l;
double d =10;
double d1 = 10.0;
double d2 = 10l;
double d3 = 10D;
double d4 = 10f;
___________________________________________________________________________________