Tokens, Escape Sequences, Variables & Identifiers in Java – ICSE
📘 ICSE Notes – Java Fundamentals
✅ Tokens, Escape Sequences, Variables & Identifiers in Java
🔹 1. Escape Sequences
✅ Definition:
Escape sequences are special characters used inside output statements to perform special tasks like moving to a new line, giving space, etc.
They always start with a backslash ( \ ).
✅ Common Escape Sequences:
| Escape Code | Meaning |
|---|---|
| \n | New Line |
| \t | Tab Space |
| \ | Backslash |
| " | Double Quotes |
| \b | Backspace |
✅ Example:
System.out.println("Hello\nWorld");
👉 Output:
Hello
World
🔹 2. Tokens
✅ Definition:
Tokens are the smallest units of a Java program.
✅ Types of Tokens:
-
Operators
-
Separators
🔹 3. Reserved Keywords
✅ Definition:
Keywords are special reserved words in Java that have predefined meanings.
👉 They cannot be used as variable names.
✅ Examples:
🔹 4. Identifiers
✅ Definition:
Identifiers are the names given to variables, classes, methods, etc.
✅ Example:
int marks;
String name;
Here:
-
marks → identifier
-
name → identifier
🔹 5. Naming Rules for Identifiers
✅ Rules:
1️⃣ Must start with:
-
letter OR underscore (_)
2️⃣ Cannot start with number
❌ 2marks (Wrong)
✅ marks2 (Correct)
3️⃣ No spaces allowed
❌ total marks
✅ totalMarks
4️⃣ Cannot be a keyword
❌ int class
✅ int className
5️⃣ Special symbols not allowed except _ and $
🔹 6. Literals (Constants)
✅ Definition:
Literals are fixed values that do not change during program execution.
✅ Types:
| Type | Example |
|---|---|
| Integer Literal | 10, 25 |
| Float Literal | 3.14 |
| Character Literal | 'A' |
| String Literal | "Hello" |
| Boolean Literal | true, false |
🔹 7. Variables
✅ Definition:
A variable is a named memory location used to store data.
👉 Value of variable can change during program execution.
✅ Example:
int age = 15;
Here:
-
age → variable
-
15 → value
🔹 8. Variable Declaration & Initialization
✅ Declaration:
Creating a variable.
Example:
int marks;
✅ Initialization:
Assigning value to variable.
Example:
marks = 90;
✅ Declaration + Initialization Together:
int marks = 90;
📊 QUICK REVISION TABLE
| Topic | Simple Meaning |
|---|---|
| Escape Sequence | Special characters for formatting output |
| Tokens | Smallest units of program |
| Keywords | Reserved words |
| Identifiers | Names given to variables |
| Literals | Fixed values |
| Variables | Store data |
| Declaration | Creating variable |
| Initialization | Assigning value |
🧠 MIND MAPS
🧠 1. Escape Sequence Mind Map
Escape Sequences
│
├── \n → New Line
├── \t → Tab
├── \" → Quotes
├── \\ → Backslash
└── Used in Output Formatting
🧠 2. Tokens Mind Map
Tokens
│
├── Keywords
├── Identifiers
├── Literals
├── Operators
└── Separators
🧠 3. Keywords Mind Map
Keywords
│
├── Reserved Words
├── Predefined Meaning
├── Cannot be used as names
└── Examples: int, class, if
🧠 4. Identifiers Mind Map
Identifiers
│
├── Names of variables
├── Names of classes
├── Names of methods
└── Follow naming rules
🧠 5. Naming Rules Mind Map
Identifier Rules
│
├── Start with letter or _
├── No spaces
├── No keywords
├── No special symbols
└── Cannot start with number
🧠 6. Literals Mind Map
Literals
│
├── Integer
├── Float
├── Character
├── String
└── Boolean
🧠 7. Variables Mind Map
Variables
│
├── Store Data
├── Value can change
├── Has Name
└── Has Data Type

Comments
Post a Comment