PARADIGM (QUIZ 2)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards
  1. What will be the r-value in the assignment int marks = 95;?

    a) marks
    b) int
    c) 95
    d) =

2
New cards
  1. 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

3
New cards
  1. 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

4
New cards
  1. In static binding, which binding time is most appropriate for associating variable types?

    a) Runtime
    b) Load time
    c) Compile time
    d) Execution time

5
New cards
  1. 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

6
New cards
  1. 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

7
New cards
  1. 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

8
New cards
  1. 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

9
New cards
  1. Which of the following languages allows implicit declarations?

    a) Python
    b) C
    c) Java
    d) FORTRAN

10
New cards
  1. 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

11
New cards
  1. 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

12
New cards
  1. 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

13
New cards
  1. 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

14
New cards
  1. Which situation is an example of a name with a connector character allowed?

    a) total-number
    b) totalNumber
    c) total number
    d) total@number

15
New cards
  1. 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

16
New cards
  1. 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.

17
New cards
  1. 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.

18
New cards
  1. 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

19
New cards
  1. 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.

20
New cards
  1. 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.