Java is not a dynamically typed language; it is a statically typed language. This means that variable types are checked at compile-time, not at runtime.
Static Typing in Java
When you declare a variable in Java, you must specify its type explicitly.
Once assigned, the type cannot change.
Example:
int num = 10; // 'num' is explicitly declared as an integer
num = "Hello"; // ❌ Compile-time error: incompatible types
This strict type-checking helps catch errors early, making Java a strongly typed and statically typed language.
Discusssion
Login to discuss.