0% found this document useful (0 votes)
4 views3 pages

Class 4

Java
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Class 4

Java
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Date: 27-04-2024

___________________

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

Access Modifier keywords:


--------------------------------------
-> public, protected, private

Primitive data type keywords:


-------------------------------------------
-> byte, short, int, long, float, double, boolean, char

Class level keywords:


-------------------------------
-> extends, implements, abstract, static, class, interface, instanceof, this,
super, final

Return type keywords:


---------------------------------
-> void, return

Conditional and looping stat keywords:


---------------------------------------------------------
-> if, else, else if, while, for, switch, case, default

Break and Continue keywords:


-------------------------------------------
-> break, continue

Exception handling keywords:


-------------------------------------------
-> throw, throws, try, catch, finally

Package level keyword:


---------------------------------
-> package

Object keywords:
--------------------------
-> new, null

Data types in Java:


----------------------------
-> To store data in a single variable with the specified data type is called
variable
-> There are two types of data types in Java:
=> Primitive data types
=> Non-primitive data types

Primitive data type:


-----------------------------
-> These data types have fixed size and range
-> There are eight types
Data Types
|
|----------------------------------------------------------
-----------------------------|
Primitive data type
Non-primitive data type
|
|-------------------------------------|--------------------------------
-|
Numeric Character Boolean
| | |
|------------------------------| |- char
|- boolean
Integer Floating point
| |
|- byte |- float
|- short |- double
|- int
|- long

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;
___________________________________________________________________________________

You might also like