









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










What is iteration?
Answer: A programming technique that uses loops to repeatedly execute a block of code while maintaining state through variables.
How does iteration differ from recursion?
Answer: Iteration uses loops and is generally more memory efficient, while recursion involves function calls and can risk stack overflow.
What is a tail recursion?
Answer: A specific form of recursion where the recursive call is the last operation in the function, allowing for optimization by reusing the stack frame.
What are the trade-offs between recursion and iteration?
Answer: Recursion is often clearer for problems with natural order but risks stack overflow, while iteration is more memory-efficient but can be more complex.
What is type checking?
Answer: The process of verifying that a program adheres to the defined types of data, ensuring correct operations.
What is polymorphism in programming?
Answer: The ability of different data types to be treated as instances of the same type through a common interface.
What is the significance of composite data types?
Answer: They are data types that can hold multiple values, such as arrays and structures, allowing for more complex data manipulation.
What is a user-defined data type?
Answer: A data type created by the programmer to encapsulate data and functions that operate on that data.
How do programming languages handle memory for primitive types?
Answer: Some languages, like C, require manual management, while others, like Python, handle it automatically.
What is the impact of hardware on primitive data types?
Answer: The size and representation of primitive types can vary based on the platform, affecting portability and performance.
What is the role of control structures in structured programming?
Answer: They dictate the flow of execution in a program, enhancing clarity and maintainability.
What is the purpose of modular programming?
Answer: To break programs into smaller, reusable, and testable components, improving organization and clarity.
What is the significance of the 'if' and 'while' constructs in structured programming?
Answer: They provide controlled flow of logic, replacing unstructured jumps like 'goto' to enhance code clarity.
What does the term 'spaghetti code' refer to?
Answer: Code that is tangled and difficult to follow, often resulting from excessive use of unstructured programming techniques.
How do modern languages connect recursion and iteration?
Answer: They may optimize recursive calls into iterative forms to improve performance and manage resources effectively.
What is the main advantage of pass-by-value?
Answer: It guards against errors by ensuring the caller's variable remains unchanged.
What is a closure in programming?
Answer: A function that captures the lexical scope in which it was defined, allowing it to access variables from that scope even when called outside of it.
What is the impact of overusing global variables in procedures?
Answer: It can ruin modularity and cause bugs due to unintended side effects.
How do modern languages like Rust improve reliability in procedures?
Answer: By imposing strict scoping and ownership rules.
What is the role of profilers in programming?
Answer: They help identify performance issues related to recursion and state changes in iterative code.
What is the purpose of using procedures and functions in programming?
Answer: To create modular, reusable code that improves readability and maintainability.
What is the significance of parameter passing techniques?
Answer: They define how arguments are transferred to functions, affecting behavior and efficiency.
What is the result of using pass-by-reference?
Answer: It allows the function to modify the caller's variable directly since it passes a reference to the original variable.
What are some common parameter passing methods?
Answer: Pass-by-value, pass-by-reference, pass-by-name, and pass- by-result.
What does lazy evaluation in functional languages do?
Answer: It delays the evaluation of an expression until its value is needed, optimizing resource use.
How does the call stack handle nested function calls?
Answer: Each function call creates a new activation record on the stack, maintaining proper scoping and local variable separation.
What is the purpose of debugging tools like GDB?
Answer: They help programmers follow function calls and variable states to identify issues in the code.
What happens to activation records when a function call is completed?
Answer: The system removes the activation record from the stack, restoring the caller's state.
What is a potential downside of using recursion?
Answer: It can lead to stack overflow if not managed properly, especially in languages that do not optimize tail calls.
What is the relationship between procedures/functions and structured programming?
Answer: They allow for dividing large programs into smaller, manageable units, enhancing code readability and maintainability.
What is the effect of inlining on function performance?
Answer: Inlining can improve performance by eliminating the overhead of function calls.
What is pass-by-name?
Answer: A method that postpones argument evaluation until the parameter is used, allowing for lazy evaluation.
What is pass-by-result?
Answer: A method that copies the final value of a parameter back to the argument after a procedure finishes.
What is the significance of understanding parameter passing methods?
Answer: It helps prevent errors and ensures that code behaves as expected, especially in object-oriented programming.
What are closures in programming?
Answer: Functions that capture their surrounding environment, retaining access to variables from their defining scope.
How are closures useful in JavaScript?
Answer: They allow data privacy and help with callbacks in event- driven programming.
What are higher-order functions?
Answer: Functions that take other functions as arguments or return them as results, treating functions as first-class citizens.
Give an example of a higher-order function in Python.
Answer: map(lambda x: x2, [1, 2, 3]) applies a doubling function to a list.*
What advantages do higher-order functions provide?
Answer: They enable abstraction over common patterns, promote concise code, and enhance reusability.
What is functional programming (FP)?
Answer: A programming paradigm that emphasizes pure functions, immutability, and higher-order functions.
What does immutability mean in functional programming?
Answer: It means that data cannot be changed after its creation, preventing accidental state changes.
What is referential transparency?
Answer: A property where a function's result is consistent for the same input, allowing for easier reasoning about code.
What are first-class functions?
Answer: Functions that can be treated as values, allowing them to be passed as arguments or returned from other functions.
What is the benefit of function composition in FP?
Answer: It allows simple operations to be combined into complex ones, enhancing modular design.
What challenges might developers face when learning functional programming?
Answer: They may struggle with the abstract qualities of FP and the shift from imperative programming paradigms.
How does FP improve code reliability?
Answer: By reducing side effects, making functions easier to test and verify independently.
What is the role of closures in state management?
Answer: Functional Programming (FP)
Which programming language combines functional ideas with practical features for big data?
Answer: Clojure
What is the primary focus of Functional Programming?
Answer: Simplicity, correctness, and scalability
Who developed lambda calculus?
Answer: Alonzo Church
What are the three main parts of lambda calculus?
Answer: Variables, lambda abstractions, and applications
What does beta reduction refer to in lambda calculus?
Answer: The process of simplifying function applications
What is a pure function?
Answer: A function that always produces the same output for the same input without side effects
Give an example of a pure function in OCaml.
Answer: let square x = x * x
What is an impure function?
Answer: A function that causes side effects or relies on outside conditions
What is the significance of monads in functional programming?
Answer: They help maintain purity by managing side effects
What are the core principles of Object-Oriented Programming (OOP)?
Answer: Encapsulation, inheritance, and polymorphism
What is a class in OOP?
Answer: A blueprint that defines attributes and methods for creating objects
What is an object in OOP?
Answer: An instance of a class created during program execution
What does encapsulation achieve in OOP?
Answer: It hides the internal workings of a class behind a public interface
What is inheritance in OOP?
Answer: A mechanism where a new class can inherit attributes and methods from an existing class
What does polymorphism allow in OOP?
Answer: It allows methods to do different things based on the object it is acting upon
What is the purpose of UML diagrams in OOP?
Answer: To visualize class structures and relationships
What is the SOLID principle in OOP?
Answer: A set of design principles aimed at making software designs more understandable, flexible, and maintainable
What is the purpose of data classes in modern programming languages?
Answer: To hold data concisely.
What performance consideration is important in Java regarding object creation?
Answer: Object creation overhead requires optimization.
What are the two main ways to reuse and arrange code in OOP?
Answer: Inheritance and composition.
What type of connection does inheritance create between classes?
Answer: An 'is-a' connection.
In C++, how does a Dog class inherit from an Animal class?
Answer: Using the syntax: class Dog : public Animal.
What does composition create between classes?
Answer: A 'has-a' connection.
Give an example of composition in programming.
Answer: A Car class having an Engine object.
What is a fragile base class problem?
Answer: It occurs when a superclass changes, breaking its subclass.
What is one risk associated with inheritance?
Answer: Overgeneralization, where unrelated behaviors complicate maintenance.
What design principle do the Gang of Four's patterns favor?
Answer: Composition over inheritance.
What does polymorphism allow in object-oriented programming?
Answer: It allows software to treat objects from different classes as instances of a main class.
What is subtype polymorphism?
Answer: It occurs when a subclass replaces a method from its superclass.
What principle does polymorphism adhere to that allows for code growth?
Answer: The Open-Closed Principle.
What is dynamic binding in programming?
Answer: It resolves method calls at runtime using an object's actual type.
How does dynamic binding affect performance compared to static binding?
Answer: Dynamic binding incurs a speed cost compared to static binding.
What is encapsulation in object-oriented programming?
Answer: It combines data and methods into one unit and restricts direct access to internal data.
What is the purpose of access control mechanisms?
Answer: To specify how much a class member is visible to other parts of the program.
What are common access modifiers in programming?
What advanced feature in Julia enhances polymorphism?
Answer: Multiple dispatch.
What should developers consider when using polymorphism and dynamic binding?
Answer: They need to design carefully to prevent mistakes like wrong overrides.
What is the lifespan of an object in programming?
Answer: An object lives from its creation to its deletion, including being put in memory, used, and removed.
How does Java manage object memory?
Answer: Java uses a garbage collector to reclaim memory when no references point to an object.
What happens to an object in C++ when its scope ends?
Answer: The object dies automatically if it is on the stack; if on the heap, it must be deleted manually.
What is a potential risk of manual memory management in C++?
Answer: It can lead to memory leaks or dangling pointers if not handled correctly.