Cards (33)

  • What is the role of an assembler?
    Translates assembly code into machine code
  • How does a compiler differ from an interpreter?
    A compiler translates the whole program at once
  • When is it appropriate to use a compiler?
    When the entire program needs to be executed
  • Why is bytecode produced by some compilers?
    It serves as an intermediate step to machine code
  • What are the stages of compilation?
    Lexical analysis, syntax analysis, code generation, optimisation
  • What is the function of linkers in compilation?
    They link libraries to the executable code
  • What does a loader do?
    Copies the program into main memory for execution
  • What is assembly code?
    A low-level language easier than machine code
  • Why is machine code difficult for humans?
    It is hard to read, write, and debug
  • What is the output of a compiler called?
    Object code
  • What is the purpose of lexical analysis?
    To remove unnecessary spaces and comments
  • What does a symbol table do?
    Tracks run-time memory addresses for identifiers
  • What is syntax analysis responsible for?
    Checking phrases against language rules
  • What is semantic analysis?
    Checks for valid program logic despite valid syntax
  • What is code generation?
    Creating machine code from checked source code
  • What is code optimisation?
    Improving code efficiency by removing redundancies
  • What are libraries in programming?
    Pre-written functions for common tasks
  • How does a linker work with libraries?
    It adjusts memory addresses for library functions
  • What happens during the loading process?
    The loader relocates memory addresses for execution
  • What are the advantages of using a compiler?
    • Faster execution of programs
    • Executable code does not require an interpreter
    • Can run multiple times without recompilation
  • What are the advantages of using an interpreter?
    • Easier debugging of code
    • Immediate execution of code
    • No need to recompile for small errors
  • What are the stages of compilation in detail?
    1. Lexical analysis: Remove spaces/comments, create tokens
    2. Syntax analysis: Check phrases against language rules
    3. Semantic analysis: Validate program logic
    4. Code generation: Generate machine code
    5. Code optimisation: Improve efficiency
  • What is the process of converting source code to executable code?
    • Source code is lexed
    • Syntactically and semantically analysed
    • Optimised for efficiency
    • Executable code is generated
  • What is the role of the Java Virtual Machine (JVM)?
    • Interprets bytecode produced by Java compilers
    • Allows Java programs to run on any machine
  • What are the disadvantages of code optimisation?
    • May complicate debugging
    • Can lead to less readable code
    • Might introduce new errors
  • What are the types of programming languages based on translation methods?
    • Compiled languages: Translated entirely before execution
    • Interpreted languages: Translated line by line during execution
    • Hybrid languages: Use both compilation and interpretation
  • What is the significance of syntax rules in programming languages?
    • Define valid structures for code
    • Help in error detection during compilation
  • What is the purpose of a symbol table in compilation?
    • Keeps track of identifiers and their memory addresses
    • Aids in semantic analysis and code generation
  • What are the common types of libraries used in programming?
    • Standard libraries: Pre-written functions for common tasks
    • Custom libraries: Functions written by programmers for specific needs
  • What is the difference between high-level and low-level languages?
    • High-level languages: Easier for humans to read and write
    • Low-level languages: Closer to machine code, harder for humans
  • What is the role of the lexer in compilation?
    • Converts source code into tokens
    • Removes unnecessary elements like spaces and comments
  • What is the importance of semantic analysis in compilation?
    • Ensures that the program logic is valid
    • Detects errors that are syntactically correct but semantically incorrect
  • What is the function of the loader in the execution process?
    • Loads the executable code into memory
    • Adjusts memory addresses for execution