












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!













Name common primitive data types.
Answer: Integers (byte, short, int, long), floating-point numbers (float, double), Booleans, and characters (char).
How do primitive data types affect program execution speed?
Answer: They allow operations to run quickly as they correspond to the machine's data storage methods.
What is type safety?
Answer: The enforcement of strict rules regarding type operations to reduce errors in programming.
What is structured programming?
Answer: A programming paradigm that promotes clear, maintainable code using control structures like sequence, selection, and iteration.
Who introduced the concept of structured programming?
Answer: Edsger Dijkstra.
What are the key benefits of structured programming?
Answer: Improved code clarity, maintainability, and reliability by avoiding unstructured constructs like 'goto'.
What is recursion?
Answer: A programming technique where a function calls itself to solve smaller instances of the same problem.
Give an example of recursion in Python.
Answer: The factorial function: 'def factorial(n): return 1 if n == 0 else n * factorial(n-1)'.
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?
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 lazy evaluation in functional programming?
Answer: A strategy where expressions are not evaluated until their values are needed, improving efficiency.
What is the difference between a procedure and a function?
Answer: A procedure performs a specific task but does not return a value, while a function computes and returns a value.
What programming paradigm primarily uses recursion for tasks resembling iteration?
Answer: Functional programming languages, such as Haskell.
What is tail call optimization?
Answer: A compiler technique that transforms recursive calls into iterative processes to improve performance.
What are activation records?
Answer: Data structures used by a program's runtime to manage function calls, storing parameters, local variables, and return addresses.
What principle does the call stack operate on?
Answer: Last in, first out (LIFO) principle.
What happens during a stack overflow?
Answer: It occurs when too many activation records are pushed onto the stack, often due to deep recursion.
What is pass-by-value?
Answer: A parameter passing method that copies the argument's value into the function's parameter, creating an independent instance.
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 effect of inlining on function performance?
Answer: Inlining can improve performance by eliminating the overhead of function calls.
What is the significance of return semantics in procedures?
Answer: They define how and what value a procedure or function returns to the caller.
How do modern languages handle stack management?
Answer: They often use virtual machines to manage stack memory, allowing programs to run on different systems.
What is the role of a frame pointer in an activation record?
Answer: It connects to the caller's record, facilitating the return to the correct execution point after a function call.
What is the purpose of closures in functional programming?
Answer: To allow functions to maintain access to their lexical scope even when executed outside that scope.
What is pass-by-reference?
Answer: A method that passes the address of the argument's storage area, allowing a function to modify the original data.
How does pass-by-reference work in C++?
Answer: It allows a function to alter the caller's variable directly, as shown in the example void increment(int& x) { x++; }.
What is a potential risk of using pass-by-reference?
Answer: It can lead to unwanted side effects if the function modifies data unexpectedly.
How does Java handle parameter passing for objects and primitives?
Answer: Java uses pass-by-reference for objects and pass-by-value for primitive types.
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.*
Answer: By reducing side effects, making functions easier to test and verify independently.
What is the role of closures in state management?
Answer: Closures help maintain state in applications, particularly in event-driven programming.
What is the impact of compiler optimizations on closures?
Answer: They can reduce performance costs associated with allocating closures and function calls.
What is the relationship between closures and higher-order functions?
Answer: Closures are often the functions that higher-order functions accept or return.
What is the significance of lambda calculus in functional programming?
Answer: It serves as a foundational concept for understanding functional programming principles.
How do modern languages implement functional programming features?
Answer: Languages like Python and JavaScript incorporate functional methods such as lambda expressions and higher-order functions.
What is the purpose of using lazy evaluation in programming?
Answer: It allows for deferred computation until necessary, which can improve efficiency.
What are some common languages that support functional programming?
Answer: Lisp, Scala, Haskell, Python, and JavaScript.
What is the importance of understanding parameter passing in programming?
Answer: It helps developers avoid errors and write code that behaves as intended.
What programming paradigm uses immutability and pure components?
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 the SOLID principle in OOP?
Answer: A set of design principles aimed at making software designs more understandable, flexible, and maintainable
What is the difference between static and dynamic dispatch?
Answer: Static dispatch resolves method calls at compile time, while dynamic dispatch resolves them at runtime
What programming language treats everything as objects?
Answer: Smalltalk
What is the role of integrated development environments (IDEs) in OOP?
Answer: To provide tools like autocompletion for object methods, streamlining development
What is the significance of lambda calculus in programming languages?
Answer: It provides a foundation for understanding computation and influences functional programming design
What does the term 'higher-order functions' refer to?
Answer: Functions that can take other functions as arguments or return them as results
What is the impact of pure functions on testing?
Answer: They simplify testing because the output is determined solely by the input
What challenges do impure functions present in programming?
Answer: They complicate debugging and testing due to their dependence on external state
What is the relationship between classes and objects in OOP?
Answer: Classes act as factories for creating objects, which are instances of those classes
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.
Answer: To specify how much a class member is visible to other parts of the program.
What are common access modifiers in programming?
Answer: Public, private, and protected.
What does encapsulation help prevent?
Answer: Unwanted interference and errors in complex systems.
What is a potential downside of too strict access control?
Answer: It complicates proper use and may require workarounds like getters and setters.
How does encapsulation contribute to security in programming?
Answer: It limits access to important states, preventing bad code from making changes.
What is the role of static analyzers in relation to encapsulation?
Answer: They uphold access rules and identify access problems.
What is the balance developers need to strike with encapsulation?
Answer: Balancing safety with ease of use.
What is the significance of using interfaces in TypeScript?
Answer: They uphold polymorphic agreements.
What does the @Override annotation in Java prevent?
Answer: It prevents accidental creation of methods that override superclass methods.
What is the purpose of stack traces in polymorphic code?
Answer: To trace dynamic calls and ensure the correct method is executed.
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.
What is garbage collection?
Answer: It is an automatic memory management process that reclaims memory from objects that are no longer reachable.
What is the significance of using blocks in C#?
Answer: Using blocks ensures that resources are managed and released at the right time.
What is unification in logic programming?
Answer: It is the process of making two logical expressions identical by finding a suitable substitution for variables.
What is backtracking in logic programming?
Answer: It is a method for finding solutions by exploring possible paths and reverting when a path fails.
What is the primary focus of logic programming?
Answer: To specify 'what' a program should achieve rather than 'how' to achieve it.
What is Prolog?
Answer: A logic programming language used for writing facts and rules to infer new information.
What are facts in logic programming?
Answer: Single statements that declare true claims, forming the knowledge base.
What is a rule in logic programming?
Answer: A logical relation between facts that allows for the inference of new facts.
What is a query in logic programming?
Answer: A question posed to the logic program that triggers the inference engine to find solutions.
What is the significance of the operator ':-' in Prolog?
Answer: ':-' means 'if' and is used to define rules in logic programming.
What is the role of an inference engine?
Answer: It assesses logical statements to derive conclusions from the knowledge base.
What are the challenges of logic programming with large datasets?
Answer: Performance issues can arise due to backtracking and unification processes.
What is the relationship between logic programming and SQL?
Answer: SQL queries resemble logic programming as they also involve logical reasoning.
What is the importance of clear facts and rules in logic programming?
Answer: They prevent incorrect conclusions and ensure efficient query processing.
What does the term 'declarative programming' refer to?
Answer: A programming paradigm that expresses the logic of computation without describing its control flow.
What is the impact of unclear rules in logic programming?
Answer: They can lead to endless loops or excessive backtracking, slowing down performance.