JAVA Lecture 2
JAVA Lecture 2
Here datatype represents which type of data the reference variable can store in the memory
location, and the reference variable gives the identity to data, so as if we want to access the data
we have to call the reference variable.
• Variable Initialization:-
Variable initialization means giving values to a variable.
Ex :-
int a = 10;
So here a is a reference variable which represents a memory location in which we are storing a
value i.e 10.
• Variable utilization:-
Variable utilization means using the variable.
int a = 4;
Int b
int b = a;
Or
int a = 5;
int b = 6;
Int c;
Int c = a+b;
i.e c = 5+6;
So C=11
Data Types :- Datatypes are the keyword which represents a type of Data. It is predefined.
Data Type Description Defauult Values Size comments
Boolean True or False FALSE 1 bit
char character null 2 byte
byte numeric 0 1 byte
short numeric 0 2 byte
int numeric 0 4 byte
long numeric 0 8 byte
float decimal 0.000000 4 byte upto 7 decimal digits
0.000000000000
double decimal 000 8 byte upto 16 decimal digits
Non-Primitive Data Type or Reference Data Types:-
String: Strings are defined as an mulitple of characters. The difference between a character array and a string in Java is,
the string is designed to hold a sequence of characters in a single variable whereas, a character array is a collection of
separate char type entities.
Java Operators :-
Types Of Operators:-
• Arithmetic Operators:-This operation are used to perform any arithmetic operations in Java.
1. +
2. -
3. *
4. / = quotient
5. % = remainder
Relational Operators :- It check the relation between two entities and returns true or false.
These operators are used to check for relations like equality, greater than, less than. They return boolean result after the
comparison and are extensively used in looping statements as well as conditional if else statements.
1. == equal to
2. != not equal
3. > greater than
4. < less than
5. >= greater than or equal to
6. <= less than or equal to
Suraj = 20;
Dheeraj = 21;
(condition one) OR
(condition two) {any one
condition should be true}
A B Result
TRUE TRUE TRUE
NOT is denoted by ! TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE