A
Arun
Guest
**Rules for identifiers in java
β In Java, an identifier is the name you give to classes, methods, variables, interfaces, etc.
Rules for Identifiers in Java:
β Variables & methods β start with a lowercase letter (studentAge, calculateSum())
β Classes & interfaces β start with an uppercase letter (Student, CarDetails)
β Constants β written in UPPERCASE with underscores (MAX_VALUE, PI)
**Example Program
class StudentDetails {
int studentAge;
String studentName;
}
Syntax:
datatype variableName;
Example:
int age; // declaration
String name; // declaration
Here, age is declared as an integer, name as a string.
Syntax:
datatype variableName = value;
Example:
int age = 20; // declaration + initialization
String name = "Arun"; // initialized with value
Here, age is initialized with 20, name with "Arun".
Compiler
Translates the entire program (source code) into machine code at once.
Execution is faster.
Example: C, C++ use compilers.
Interpreter
Translates the program line by line and executes it immediately.
Execution is slower.
Example: Python, Java (partly) use interpreters.
Java uses both:
Java code is compiled by javac (compiler) into bytecode.
Then the JVM (Java Virtual Machine) interprets/executes the bytecode.
Class β A blueprint/template that defines properties and behaviors.
Object β A real-world entity created from the class.
Example:
class Car {
String color;
void drive() {
System.out.println("Car is driving");
}
}
public class Main {
public static void main(String[] args) {
Car myCar = new Car(); // Object creation
myCar.color = "Red";
myCar.drive();
}
}
ASCII (American Standard Code for Information Interchange)
7-bit code (128 characters).
Covers English letters, digits, symbols.
Example: βAβ = 65, βaβ = 97.
Unicode
16-bit or more (65,536+ characters).
Supports all languages (English, Tamil, Hindi, Chinese, etc.).
Java uses Unicode for characters.
**
Continue reading...
β In Java, an identifier is the name you give to classes, methods, variables, interfaces, etc.

- Allowed characters Letters (A-Z, a-z) Digits (0-9) Underscore (_) Dollar sign ($)
Example: myVar, student_name, $_count
Must not begin with a digit
Invalid - 1number
Valid - number1
No special characters or spaces (except _ and $)
Invalid - my-name, first name
Valid - myName, first_name
Cannot be a reserved keyword (like int, class, static, if)
Invalid: class
Valid: className
Case-sensitive
Student and student are different identifiers
No length limit:
β You can make identifiers very long, but short and meaningful names are recommended.
Convention rules (not enforced by compiler but recommended):
β Variables & methods β start with a lowercase letter (studentAge, calculateSum())
β Classes & interfaces β start with an uppercase letter (Student, CarDetails)
β Constants β written in UPPERCASE with underscores (MAX_VALUE, PI)
**Example Program
class StudentDetails {
int studentAge;
String studentName;
Code:
void displayInfo()
{
System.out.println(studentName + " is " + studentAge + " years old.");
}
}
- Declaration (Declarisation) ββ Declaration is the process of introducing a variable in a program by specifying its data type and name. At this point, memory is reserved for the variable, but it does not yet have a value (unless given a default).

datatype variableName;

int age; // declaration
String name; // declaration
Here, age is declared as an integer, name as a string.
- Initialization ββ Initialization means assigning an initial value to a declared variable. ββ It can happen at the time of declaration or later in the code.

datatype variableName = value;

int age = 20; // declaration + initialization
String name = "Arun"; // initialized with value
Here, age is initialized with 20, name with "Arun".
- Compiler and Interpreter
Compiler
Translates the entire program (source code) into machine code at once.
Execution is faster.
Example: C, C++ use compilers.
Interpreter
Translates the program line by line and executes it immediately.
Execution is slower.
Example: Python, Java (partly) use interpreters.

Java code is compiled by javac (compiler) into bytecode.
Then the JVM (Java Virtual Machine) interprets/executes the bytecode.
- Class and Object
Class β A blueprint/template that defines properties and behaviors.
Object β A real-world entity created from the class.

class Car {
String color;
void drive() {
System.out.println("Car is driving");
}
}
public class Main {
public static void main(String[] args) {
Car myCar = new Car(); // Object creation
myCar.color = "Red";
myCar.drive();
}
}
- ASCII and Unicode
ASCII (American Standard Code for Information Interchange)
7-bit code (128 characters).
Covers English letters, digits, symbols.
Example: βAβ = 65, βaβ = 97.
Unicode
16-bit or more (65,536+ characters).
Supports all languages (English, Tamil, Hindi, Chinese, etc.).
Java uses Unicode for characters.
**
Continue reading...