🧠 Understanding Variables and Memory

let a = 27;

🔁 Reference and Assignment

a = null;

🧩 Data Types in Java

Java uses data types to define the kind of value a variable can hold.

📌 Variable Creation Syntax
datatype variableName = value;
Multiple variables of the same data type

data_type variableName1 = value1, variableName2 = value2;

Example : String firstName="Arunkumar", lastName = "Selvam";
Syntax of Variable Declaration & Initialization

data_type variableName; (Variable Declaration)
data_type variaableName = value; (Variable Initialization)

String userName; // Variable Declaration
String userName = "Arunkumar"; //Variable Initialization

✍️ Examples of Data Types

Type Examples
Text char, String
Number int, float, long, double

📦 Java Data Type Categories

** Data Types in Java.png


🧮 Binary & Decimal Conversion Study Notes

📌 1 Byte = 8 Bits

A byte contains 8 bits, and each bit is either 0 or 1:

00000000

🔁 Decimal to Binary Conversion

Example: Convert 27 to binary

27 ÷ 2 = 13, remainder 1  
13 ÷ 2 = 6,  remainder 1  
6 ÷ 2  = 3,  remainder 0  
3 ÷ 2  = 1,  remainder 1  
1 ÷ 2  = 0,  remainder 1

Binary Representation of 27 = 11011


🔁 Binary to Decimal Conversion

Example: Convert 11011 to Decimal

(1 × 2⁴) + (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰)
= 16 + 8 + 0 + 2 + 1
= 27

🧠 More Practice: Convert 97 to Binary

97 ÷ 2 = 48, remainder 1  
48 ÷ 2 = 24, remainder 0  
24 ÷ 2 = 12, remainder 0  
12 ÷ 2 = 6,  remainder 0  
6 ÷ 2  = 3,  remainder 0  
3 ÷ 2  = 1,  remainder 1  
1 ÷ 2  = 0,  remainder 1

Binary of 97 = 1100001


🧮 Convert 1100001 to Decimal

(1 × 2⁶) + (1 × 2⁵) + (0 × 2⁴) + (0 × 2³) + (0 × 2²) + (0 × 2¹) + (1 × 2⁰)
= 64 + 32 + 0 + 0 + 0 + 0 + 1
= 97

Variable Naming Convention

Data Type
Size (Bytes)
Maxi and Mini Value Stored
Default Value
Byte
1
-128 to 127 0
Short
2
-32,768 to 32,767 0
Int
4
-2,147,483,648 (-231) to 2,147,483,647 (231-1). 0
Long
8
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 0L
Float
4
6 to 7 decimal point 0.0f
Double
8
15 decimal point 0.0d
Char
2
single character/letter or ASCII values is -128 to 127 '\u0000'
Boolean
1
true or false values false

Bit - Binary Digit - 0, 1s

Base 2 - 0, 1

Base 8 - 01234567

Base 10 - 0123456789

Base 16 - 0123456789ABCDEF

ASCII - American Standard for Code Information Interchange