A team compares two versions of a teaching language using 40 independent request handlers. Both versions allow addition only between integers and perform no automatic conversion.
The static version rejects any handler containing an incompatible operation anywhere in its source. The dynamic version checks an addition only when it executes. There are no other errors, and each handler receives exactly one test input.
How many more handlers does static analysis reject than fail with a type error during the dynamic tests? Answer in handlers, as an exact whole number, to zero decimal places. Compare rejected handlers with observed failing handlers.
Unlock full course notes by signing up
Read the guarantees precisely
Application S passes its language's static type analysis. Application D uses dynamic typing and completes one test successfully. Neither language promises automatic conversion of text into numbers. No other language rules or test coverage information are supplied. Which statements are justified? Select all that apply.
Separate a value from its wrapper
A sensor application defines the value domain of a type as the set of values that type permits. It uses these three types:
Reading permits exactly the integers from −2 through 2, inclusive.
Flag permits exactly the Boolean values true and false. These values are distinct from integers.
Count paths through a repair branch
A receipt routine uses three Boolean inputs: chooseText, repair, and runAdd. Each can independently be true or false, giving eight distinct input combinations. Indentation identifies the statement controlled by each if.
In the dynamic version, variables may change value types. Addition accepts only two integers, performs no conversion, and stops the routine on a type error. A successful print displays one number.
In the static version, the first line is instead var amount: Int = 10. Integer variables may receive only integers, and analysis rejects an incompatible assignment anywhere in the source before execution, including inside a branch.
Count representable and valid job states
A job tracker currently stores every job as a record containing all four fields below. Each field is an enumeration: its listed names are distinct values with no associated data. Initially, every combination of field values is permitted by the record type.
The application imposes additional business rules:
A proposed replacement is a tagged union, which stores exactly one named alternative together with that alternative's fields. Its alternatives are Ready(stage, worker), Failed(error) and Waiting. In this replacement, Ready uses the four listed stages and three listed workers, Failed uses only Disk, Network or Input, and Waiting has no fields.