📢 Join My WhatsApp Channel JavaWithSumit

Get Daily ICSE Java Notes, Programs & Exam Tips 🚀

👉 Join Now

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:

  1. Keywords

  2. Identifiers

  3. Literals

  4. Operators

  5. 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 Literal10, 25
Float Literal3.14
Character Literal'A'
String Literal"Hello"
Boolean Literaltrue, 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 SequenceSpecial characters for formatting output
TokensSmallest units of program
KeywordsReserved words
IdentifiersNames given to variables
LiteralsFixed values
VariablesStore data
DeclarationCreating variable
InitializationAssigning 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

🧠 8. Declaration & Initialization Mind Map

Variables

├── Declaration → int x;
├── Initialization → x = 10;
└── Both Together → int x = 10;





Referenced: ChatGPT, Total Computer Application(Morning Star)


Comments

Popular posts from this blog

Introduction to Object Oriented Programming and Java- ICSE Notes

Introduction to OOP's

Object Modelling – Entities and Their Behaviour in Java