1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What will be the r-value in the assignment int marks = 95;?
a) marks
b) int
c) 95
d) =
What is the main disadvantage of using aliases in programming?
a) They reduce runtime efficiency
b) They increase memory usage
c) They harm readability and introduce side effects
d) They prevent function calls from executing
Which of the following is most likely a type error?
a) Comparing int with float
b) Assigning a string to an integer variable
c) Using coercion in operations
d) Declaring a variable twice
In static binding, which binding time is most appropriate for associating variable types?
a) Runtime
b) Load time
c) Compile time
d) Execution time
Which attribute of a variable defines what values it can store and what operations it can perform?
a) Address
b) Type
c) Scope
d) Value
Which scenario best illustrates a violation of type compatibility in structured types?
a) Assigning an int to a float variable
b) Assigning a struct A with field x to struct B with field x
c) Using a reserved keyword as a variable name
d) Initializing a string with null
If variable x is declared in MAIN, and SUB2 accesses it after being called by SUB1, what does static scoping resolve x as?
a) SUB1’s x
b) MAIN’s x
c) SUB2’s x
d) Undefined
What is the difference between a reserved word and an identifier?
a) Reserved words can be redefined; identifiers cannot
b) Reserved words are user-defined, identifiers are built-in
c) Reserved words have fixed meaning in the language and cannot be used as names
d) Reserved words are constants only
Which of the following languages allows implicit declarations?
a) Python
b) C
c) Java
d) FORTRAN
Given the code for (int i = 0; i < 5; i++) { int x = i; }, the variable x is best described as:
a) A static scoped variable
b) A dynamic scoped variable
c) A global variable
d) A block-local variable
When is a binding considered dynamic?
a) When it occurs during compilation
b) When it remains unchanged throughout execution
c) When it occurs at runtime and may change
d) When the program is loaded into memory
Why is dynamic scoping discouraged in large-scale systems?
a) It reduces execution time
b) It leads to tightly scoped variables
c) It sacrifices readability and predictability
d) It is incompatible with object-oriented programming
Which of the following best explains the coercion process in type checking?
a) Replacing reserved keywords with synonyms
b) Implicitly converting one type to another during assignment
c) Declaring variables without types
d) Preventing use of dynamic typing in C
Which situation is an example of a name with a connector character allowed?
a) total-number
b) totalNumber
c) total number
d) total@number
Which type compatibility rule allows assigning between two types with the same internal structure but different names?
a) Nominal typing
b) Declarative typing
c) Structural typing
d) Binding typing
Consider a situation where a lexical analyzer fails to properly group alphanumeric characters into identifiers. What impact will this have on the parser and the overall compilation process?
a) The parser will infer tokens using recovery routines, avoiding syntax errors.
b) The parse tree will be larger but still semantically valid.
c) The parser will receive incorrect tokens, leading to syntax errors and invalid parse structures.
d) The lexical analyzer will pass on string literals instead of identifiers, which can be corrected by semantic analysis.
In bottom-up parsing, what distinguishes a "handle" from other phrases in the sentential form?
a) It is the shortest possible reduction.
b) It corresponds to the deepest subtree in the parse tree.
c) It is the leftmost substring matching the RHS of a grammar rule.
d) It is the rightmost simple phrase that can be reduced at that step.
You are tasked with designing a recursive-descent parser for the grammar below. What primary issue must be addressed before the grammar can be used?
<stmt> → <stmt> ; <expr> | <expr>
a) The grammar lacks pairwise disjointness
b) The grammar contains indirect left recursion
c) The grammar contains direct left recursion
d) The grammar is ambiguous in its terminals
Which situation would most likely cause an LL parser to fail even if the grammar has no left recursion?
a) The FIRST sets for multiple right-hand sides of a nonterminal are disjoint.
b) There is ambiguity in operator precedence within expressions.
c) The grammar has nullable productions with overlapping FIRST sets.
d) The grammar contains no terminals in its production rules.
Given a lexical analyzer built using a state diagram, what challenge may arise when reserved words and identifiers are handled in separate diagram sections rather than using a lookup table?
a) It improves recognition speed but complicates syntax analysis.
b) It increases portability but introduces ambiguity during token classification.
c) It causes redundancy and inflexibility in design, especially when extending language keywords.
d) It enhances clarity but prevents detection of implicit declarations.