Академический Документы
Профессиональный Документы
Культура Документы
DATA Type
Data Type
Data Type Default Default Minimum Value Max Value
Value size
boolean false 1 bit Stores true or false
values
'\u0000' 2 byte Stores a single
char character/letter or
ASCII values
0 1 byte -128 (-2^7) 127 (inclusive)(2^7 -1)
byte
short 0 2 byte -32,768 (-2^15) 32,767 (inclusive) (2^15 -1)
int 0 4 byte (-2^31) (2^31 -1)
long 0L 8 byte (-2^63) (2^63 -1)
float 0.0f 4 byte Stores fractional
numbers. Sufficient for
storing 6 to 7 decimal
digits
0.0d 8 byte Stores fractional
double numbers. Sufficient for
storing 15 decimal
digits
Type Casting
Casting is the temporary conversion of a variable from its original data type to some
other data type.
Like being cast for a part in a play or movie
With primitive data types if a cast is necessary from a less inclusive data type to a more
inclusive data type it is done automatically.
int x = 5;
double a = 3.5;
double b = a * x + a / x;
double c = x / 2;
if a cast is necessary from a more inclusive to a less inclusive data type the class must be
done explicitly by the programmer
Unary Operator,
Arithmetic Operator,
Shift Operator,
Relational Operator,
Bitwise Operator,
Logical Operator,
Ternary Operator
Assignment Operator.
Operator Category Precedence
Type
if statement
if-else statement
if-else-if ladder
nested if statement
Java Switch Statement
for loop
while loop
do-while loop
Example
For Loop while loop Do-while
for(Type var:array)
{
//code to be executed
}
Objects and Classes in Java
Object Definitions:
Fields
Methods
Constructors
Blocks
Nested class and interface
Object and Class Example: main within the class
By reference variable
S1.name=”Sukanya”;
By method (By passing Values
s1.insertRecord(111,"Aayushi"); )
By constructor
Constructors in Java
the object.
Every time an object is created using the new() keyword,
There are many ways to copy the values of one object into
another in Java. They are:
By constructor
By assigning the values of one object into another