Which of the following is a key distinction between a statically typed and a…

2025

Which of the following is a key distinction between a statically typed and a dynamically typed programming language in the context of compiler design?

  1. A.

    Dynamically typed languages require no type information at any stage.

  2. B.

    Dynamic typing ensures better performance by avoiding type declarations.

  3. C.

    Static typing allows code to be compiled without lexical analysis.

  4. D.

    Static typing enforces type checking during compilation, whereas dynamic typing defers it until runtime.

Attempted by 30 students.

Show answer & explanation

Correct answer: D

Statically typed languages perform type checking at compile time, while dynamically typed languages check types at runtime. This distinction affects error detection timing and performance characteristics in compiler design.


Note for more understanding

The major distinction between static typing and dynamic typing lies in when type checking occurs.

Static Typing
Type checking happens during compilation.
Variables usually have declared data types.
Errors are detected before program execution.

Example:

int x = "Hello";   // Compile-time error

Languages:

C
C++
Java
Dynamic Typing
Type checking occurs at runtime.
Variables can hold values of different types during execution.
Some type errors appear only while the program runs.

Example:

x = "Hello"
x = 10

Languages:

Python
JavaScript
Ruby

Thus, Option D correctly describes the key difference.

Explore the full course: Niacl Ao It Specialist