Programming Language Concepts - paradigms, models, programming environments, binding times, syntax and translation stages - Question Bank

1. A 'parse tree' represents the syntactic structure of a program, which is generated by the:
A) Lexical Analyzer
B) Syntax Analyzer (Parser)
C) Semantic Analyzer
D) Optimizer
2. The process of assigning memory to a variable during program execution is an example of binding at:
A) Compile-time
B) Link-time
C) Load-time
D) Run-time
3. Which of the following is a characteristic of a 'declarative' programming approach?
A) Explicit control over program flow.
B) Focus on describing the desired outcome.
C) Use of mutable state and side effects.
D) Step-by-step instruction sequences.
4. What is the main advantage of using an interpreter over a compiler for certain tasks?
A) Faster execution speed for all programs.
B) Easier debugging and faster development cycles.
C) Generation of more compact machine code.
D) Better memory management.
5. A 'symbol table' is primarily used by which compiler stages?
A) Lexical Analysis and Code Generation
B) Syntax Analysis and Optimization
C) Semantic Analysis and Code Generation
D) Lexical Analysis and Syntax Analysis
6. Which paradigm uses recursion and immutability as core concepts?
A) Imperative
B) Object-Oriented
C) Functional
D) Procedural
7. What is a 'syntax error'?
A) A logical error in the program's computation.
B) A violation of the programming language's grammatical rules.
C) An error that occurs when the program is running.
D) A type mismatch between variables.
8. Which binding time is associated with the definition of language keywords and operators?
A) Compile-time
B) Run-time
C) Link-time
D) Language design-time
9. In the context of programming language translation, what is 'intermediate representation'?
A) The original source code.
B) The final machine code.
C) An abstract form of the program that is easier to optimize and translate.
D) A set of tokens.
10. The concept of 'encapsulation' is central to which programming paradigm?
A) Functional Programming
B) Procedural Programming
C) Object-Oriented Programming
D) Logic Programming
11. Which translation stage deals with the structure and grammar of the code?
A) Lexical Analysis
B) Syntax Analysis
C) Semantic Analysis
D) Code Generation
12. What is the role of a 'debugger' in a programming environment?
A) To translate code into machine language.
B) To help programmers find and fix errors in their code.
C) To optimize the execution speed of the program.
D) To manage project dependencies.
13. Static typing in a programming language means type checking is primarily done at:
A) Run-time
B) Load-time
C) Compile-time
D) Execution-time
14. A dynamic language typically performs more binding at:
A) Compile-time
B) Link-time
C) Run-time
D) Language design-time
15. Which of the following is NOT typically considered a programming paradigm?
A) Object-Oriented
B) Procedural
C) Imperative
D) Compilation
16. What is a common characteristic of 'pure' functional programming languages?
A) Extensive use of global mutable state.
B) Absence of side effects.
C) Heavy reliance on loops and assignments.
D) Implicit state changes.
17. Which programming model focuses on the flow of control and data through a sequence of operations?
A) Functional Model
B) Object-Oriented Model
C) Imperative Model
D) Logic Model
18. What is the primary goal of the 'code generator' stage?
A) To create tokens from source code.
B) To build an abstract syntax tree.
C) To produce target machine code or intermediate code.
D) To optimize the intermediate code.
19. Type checking is typically performed during which translation stage?
A) Lexical Analysis
B) Syntax Analysis
C) Semantic Analysis
D) Code Generation
20. Which translation stage is responsible for identifying if a sequence of tokens forms a valid structure according to the grammar rules?
A) Lexical Analyzer
B) Syntax Analyzer (Parser)
C) Semantic Analyzer
D) Code Generator
21. What is a 'token' in lexical analysis?
A) A complete program statement.
B) A keyword or identifier in the source code.
C) A sequence of characters representing a meaningful unit.
D) An error message.
22. The association of a variable name with its scope is an example of binding that occurs at:
A) Language design-time
B) Compile-time or interpretation-time
C) Link-time
D) Execution-time
23. Which binding time is associated with the process of connecting different pieces of compiled code?
A) Compile-time
B) Load-time
C) Link-time
D) Run-time
24. Just-In-Time (JIT) compilation is a technique often used in:
A) Traditional compiled languages like C.
B) Interpreted languages like Python.
C) Environments that compile bytecode to native machine code during runtime.
D) Assembly language programming.
25. What is a 'virtual machine' in the context of programming environments?
A) A physical computer.
B) A software emulation of a physical computer, often used for executing bytecode.
C) A hardware component for graphics processing.
D) A network router.
26. SQL (Structured Query Language) is a prime example of which programming paradigm?
A) Imperative
B) Procedural
C) Declarative
D) Object-Oriented
27. Which programming paradigm is characterized by a focus on 'what' needs to be computed rather than 'how'?
A) Imperative Programming
B) Declarative Programming
C) Structured Programming
D) Object-Oriented Programming
28. The 'linker' is responsible for:
A) Translating source code to machine code.
B) Combining object files and libraries into an executable program.
C) Analyzing the meaning of program statements.
D) Detecting syntax errors.
29. What is the final stage of a typical compiler?
A) Lexical analysis
B) Semantic analysis
C) Code generation
D) Linking
30. Code optimization aims to:
A) Increase the size of the generated code.
B) Make the code run slower.
C) Improve the efficiency (speed, size) of the intermediate or target code.
D) Introduce new syntax errors.
31. Intermediate code generation typically occurs after which stage?
A) Lexical analysis
B) Syntax analysis
C) Semantic analysis
D) Code optimization
32. What is the purpose of the 'semantic analyzer' in a compiler?
A) To check for correct statement structure.
B) To check for type consistency and other meaning-related errors.
C) To generate machine code.
D) To break the code into tokens.
33. Syntax analysis (parsing) checks the source code for:
A) Semantic errors.
B) Lexical errors.
C) Grammatical correctness according to the language's syntax rules.
D) Runtime errors.
34. What is the output of the 'parser' in a compiler?
A) A sequence of tokens.
B) Optimized machine code.
C) An Abstract Syntax Tree (AST) or Parse Tree.
D) A symbol table.
35. Lexical analysis (scanning) breaks the source code into:
A) Abstract syntax trees.
B) Executable machine instructions.
C) Tokens.
D) Symbol tables.
36. What is the typical first stage in the translation process of a compiled language?
A) Code generation
B) Optimization
C) Lexical analysis (Scanning)
D) Linking
37. An 'interpreter' typically executes source code by:
A) Translating the entire program into machine code before execution.
B) Executing the source code instruction by instruction without prior translation.
C) Compiling the code into an intermediate bytecode.
D) Linking pre-compiled libraries.
38. What is the primary role of a 'compiler'?
A) To execute code directly on the hardware.
B) To translate source code from one language to another (e.g., high-level to machine code).
C) To manage memory allocation during runtime.
D) To provide a user interface for writing code.
39. Which of the following describes the 'semantics' of a programming language?
A) The arrangement of keywords.
B) The set of rules for writing statements.
C) The meaning of statements.
D) The visual appearance of code.
40. What is 'syntax' in the context of programming languages?
A) The meaning of statements.
B) The rules governing the structure of valid statements.
C) The efficiency of code execution.
D) The type of data a variable can hold.
41. Binding a variable to a memory location typically happens at which binding time?
A) Language design-time
B) Compile-time or run-time
C) Load-time
D) Execution-time
42. Which binding time occurs earliest in the software development lifecycle?
A) Link-time binding
B) Runtime binding
C) Compile-time binding
D) Language design-time binding
43. Binding refers to the association of a name with a thing. What is 'binding time'?
A) The time a variable is declared.
B) The time at which a given binding is made.
C) The time a program finishes execution.
D) The time a compiler is written.
44. Which of the following is an example of a programming environment component?
A) Operating System Kernel
B) Device Driver
C) Integrated Development Environment (IDE)
D) Network Protocol Stack
45. What does a 'programming environment' typically include?
A) Only a compiler
B) A text editor, debugger, and compiler/interpreter
C) Just a runtime system
D) A hardware specification document
46. Which programming paradigm is based on mathematical logic and formal reasoning?
A) Declarative Programming
B) Logic Programming
C) Event-Driven Programming
D) Aspect-Oriented Programming
47. What is a common model for imperative programming?
A) Lambda calculus
B) State transformation
C) Pattern matching
D) Constraint satisfaction
48. In functional programming, what is a key characteristic of functions?
A) They modify external state.
B) They always return the same output for the same input.
C) They have side effects.
D) They rely heavily on mutable data.
49. Which programming paradigm emphasizes the concept of 'objects' with data and methods?
A) Functional Programming
B) Procedural Programming
C) Object-Oriented Programming
D) Logic Programming