Machine-translated by Google. Questions are authored in English.
Top

Symbol Table Management Questions and Answers

21.

State whether the following is true or false.
A name declared in an inner block permanently removes the outer declaration from the symbol table.

Answer: A

The outer entry is hidden rather than deleted, and becomes visible again when the inner block ends. A stacked or chained table implements this restoration naturally. Deleting the outer entry would make the enclosing code fail to compile.

Please log in or register to report this question.

Answer: B

Correct answer: the most recent binding in the call chain at run time

Dynamic scoping looks outward through the chain of active calls rather than outward through the enclosing text, so which declaration a name refers to depends on who called the procedure. It cannot be resolved at compile time, which is why static scoping is almost universal in modern languages.

Please log in or register to report this question.

23.

Assertion (A): A compiler for a statically scoped language can resolve every name at compile time.
Reason (R): Visibility depends only on the nesting of blocks in the program text, which the compiler can see in full.

Answer: C

Both are true and the reason gives the mechanism, and it explains why static scoping is universal. A dynamically scoped language would have to search a chain of bindings at run time, costing both speed and predictability.

Please log in or register to report this question.

Answer: D

The same spelling may be a struct tag and a variable simultaneously without conflict. The compiler keeps separate tables or tags each entry with the space it belongs to. Languages differ considerably in how many such spaces they define.

Please log in or register to report this question.

Answer: A

Overload resolution selects among the candidates using the argument types at the call. The symbol table must therefore be able to hold several entries under one name. A chain of candidates under one key is the usual arrangement.

Please log in or register to report this question.

Answer: B

Every visible candidate must be available so the best match can be chosen. Discarding all but one at declaration time would make correct resolution impossible. Some languages also permit the return type to participate in the choice.

Please log in or register to report this question.

Answer: C

Correct answer: appears in the text before the declaration of that name

A forward reference forces the compiler either to make two passes, or to record the use and patch it when the declaration arrives. Languages requiring declaration before use avoid the difficulty; those permitting mutual recursion between procedures must deal with it somehow.

Please log in or register to report this question.

Answer: D

Correct answer: the attributes of every name are known when the use is compiled

With the declaration guaranteed to have been seen already, the type, the scope and the storage are all in the symbol table when the use is compiled, so code and checks can be generated on the spot. Without that guarantee the compiler must defer, and a second pass or a patching mechanism becomes necessary.

Please log in or register to report this question.

Answer: A

The forward declaration installs the signature so calls can be compiled before the body appears. The body must then match the declaration exactly or an error is reported. C header files exist largely to supply exactly these forward declarations.

Please log in or register to report this question.

Answer: B

Calls are checked against the parameter list and the return type participates in expression typing. A pointer to the procedure's own local table is often held as well. Nested procedures make that chain of tables mirror the source structure.

Please log in or register to report this question.

Loading…
Tags: Symbol Table Management Questions and Answers || Symbol Table Management MCQ Questions and Answers || Symbol Table Management GK Questions and Answers || Symbol Table Management GK MCQ Questions || Symbol Table Management Multiple Choice Questions and Answers || Symbol Table Management GK || GK on Symbol Table Management || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design