Which of the following best describes static type checking in programming languages?
Think about when the program is analyzed for type errors before running.
Static type checking means the compiler checks types before running the program, catching errors early.
In type checking rules, when is an assignment between two variables considered valid?
Consider if the language allows automatic conversion between types.
Assignments are valid if the source type can be implicitly converted to the target type, ensuring compatibility.
Given the expression a + b, which condition will cause a type error during type checking?
Think about whether the language allows adding a string and an integer directly.
If there is no implicit conversion between string and integer, adding them causes a type error.
Which statement correctly compares static and dynamic type checking?
Consider when types are checked and if declarations are mandatory.
Static type checking usually requires explicit type declarations, while dynamic type checking infers types at runtime.
In a language with subtype polymorphism, which rule ensures type safety during method calls?
Think about how method overriding respects types to maintain safety.
Covariant return types allow the subtype method to return a more specific type, preserving type safety.
