Variables
3. Examples
Java:
int age = 25; // Simple assignment
double total = 100.50; // Assigning a literal
int sum = age + 10; // Assigning an expression
Python:
age = 25 # No type declaration
total = 100.50
sum = age + 10
C++:
int age = 25;
double total = 100.50;
int sum = age + 10;
Notes
Static Typing (Java, C++): Requires explicit type declaration; type mismatches cause compile-time errors.
Dynamic Typing (Python): Type is inferred at runtime, allowing flexibility but requiring careful validation.
Compound Assignment: Combines assignment with an operation (e.g., x += 5 is equivalent to x = x + 5).
Immutability: In Java, final variables can only be assigned once (e.g., final int MAX = 100;).