
















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 a programming paradigm? A fundamental style or approach to programming that defines how problems are structured, solved, and expressed in code. What is a programming language? A set of instructions that enables humans to communicate with computers, using symbols to turn ideas into instructions. What are the essential characteristics of programming languages? Syntax, Data Types, Variables, Operators, Control Structures, Libraries and Frameworks, and Paradigms. What defines low-level programming languages? They are closer to hardware, provide little abstraction, and are difficult to write and maintain, but offer high performance. Name two examples of low-level programming languages. Assembly Language and Machine Language (binary).
What defines high-level programming languages? They provide a high level of abstraction, are easier to write and debug, and are highly portable. Name three examples of high-level programming languages. Python, Java, and C++. What is the difference between compiled and interpreted languages? Compiled languages are translated into machine code before execution, while interpreted languages are executed line-by-line during runtime. What are the advantages of compiled languages? Faster runtime, errors detected at compile time, and ideal for performance-critical applications. What are the advantages of interpreted languages? Easier to debug, faster initial execution, and highly portable. What is the imperative programming paradigm?
What is automatic memory management? Automatic memory management handles memory allocation and deallocation automatically, typically through garbage collection, as seen in Python and Java. What is manual memory management? Manual memory management requires programmers to explicitly allocate and deallocate memory, as seen in C and C++. What is garbage collection? Garbage collection is an automatic process that reclaims memory no longer in use, preventing memory leaks. What is imperative programming? Imperative programming is a paradigm where the programmer defines the sequence of operations that change the program's state. What are key characteristics of imperative programming? Key characteristics include sequential execution, explicit state changes, and the use of control structures like loops and conditionals. What are the advantages of imperative programming? Advantages include precise control over hardware, performance benefits, and straightforward implementation for procedural tasks. What are the disadvantages of imperative programming? Disadvantages include side effects, scalability issues, and complexity in state management. What is default initialization in C? In C, local variables of primitive types are not initialized by default and contain garbage values unless explicitly initialized. What is the Standard Template Library (STL) in C++? The STL is a collection of programming tools in C++ for implementing algorithms and data structures, including containers, iterators, and algorithms. What is procedural programming? Procedural programming is a paradigm based on procedure calls, structuring programs as a series of instructions grouped into procedures. What are the benefits of procedural programming? Benefits include simplicity, code reusability, and a clear program structure. What are the limitations of procedural programming?
Limitations include poor data management, lack of encapsulation, and challenges in managing large systems. What is the difference between a function and a procedure? In general, a function returns a value, while a procedure does not; in languages like Java and C++, both are often referred to as functions. What are the key components of a function? Key components include the function definition, arguments, return values, and the function body. What is recursion in programming? Recursion is a process where a function calls itself to solve a problem, typically involving a base case and recursive case. How does recursion work in programming? Recursion involves space allocation, argument copying, function execution, result storage, stack rewind, and returning control to the caller. What is the return behavior of a function after it is called? Control returns to the exact location in the program from which the function was originally invoked. What limits the depth of recursion in C and C++? The depth of recursion is typically limited by the system's stack size. How can you change the recursion limit in Python? You can change the recursion limit using sys.setrecursionlimit(). What error does Python raise when the maximum recursion depth is exceeded? Python raises a RecursionError. What is Tail Call Optimization (TCO)? TCO is a feature where the function's stack frame can be reused for tail-recursive calls, preventing stack overflow. Which programming languages typically implement Tail Call Optimization? Functional languages like Haskell and Scheme. What is a lambda function? A lambda function is an anonymous function defined using a special syntax. What is the syntax for defining a lambda function in Python? lambda arguments: expression.
Non-inline function definitions, non-const variable definitions, and using directives. What is the syntax for an inline function in C++? inline int add(int a, int b) { return a + b; } What happens during compilation of inline functions? The compiler replaces the inline function call with its code, eliminating the overhead of a function call. What is a functional interface in Java? An interface with a single abstract method, often implemented using lambda expressions. What is the role of the module-info.java file in Java? It defines a module and provides access to a set of classes and packages. How does modularization improve code organization? It allows for structuring files and folders for clarity and separation of concerns. What is the benefit of using header guards in C++? They prevent multiple inclusions of the same header file. What is the significance of the capture clause in C++ lambda functions? It allows lambda functions to capture variables from the surrounding scope. What is a higher-order function? A function that takes other functions as arguments or returns a function as a result. What is the main advantage of using lambda functions? They allow for concise function definitions and can be passed as arguments to higher-order functions. What is the impact of recursion depth on performance in Python? Recursion can be slower due to the overhead of function calls and the lack of tail call optimization. What is the purpose of using inline functions for frequently called functions? To eliminate function call overhead and improve performance.
What does modularization promote in software development? Efficient debugging and testing by isolating components. What are header guards? Header guards are directives used in header files to prevent multiple inclusions into a single .cpp file. What is the purpose of a package in programming? A package organizes related modules or classes into a structured directory format, aiding in organization, namespace management, and code reusability. How is a package defined in Python? In Python, a package is a collection of modules organized in directories, requiring an init.py file to indicate it's a package. What is the role of the import statement in Python? The import statement allows you to import entire packages or specific modules, such as 'import mypackage.module1' or 'from mypackage import module2'. What is a namespace in Java? In Java, a package serves as a namespace for organizing classes and interfaces, helping to avoid name conflicts. What are the common access modifiers in Java? Public (accessible from any class), Package-Private (default, accessible within the same package), Private (accessible only within the same class), and Protected (accessible within the same package and by subclasses).
What are the access modifiers in Python? Public (no prefix), Protected (single underscore), and Private (double underscore). What is the purpose of package management tools like Maven and Gradle? These tools handle dependencies, package management, and project structure in Java. What is the significance of the init.py file in Python packages? init.py indicates that a directory should be treated as a package, allowing for module organization. What is the difference between local and global variables? Local variables are defined within a specific block of code and have a limited lifetime, while global variables are declared outside any function and can be accessed throughout the program. What is shadowing in programming? Shadowing occurs when a local variable has the same name as a global variable, causing the local variable to take precedence within its scope. What is the role of JAR files in Java? JAR files bundle packages and their dependencies, allowing them to be shared across projects. What is the difference between pure OOP languages and not pure OOP languages? Pure OOP languages treat everything as an object, while not pure OOP languages support OOP but also allow procedural or functional programming. What are the common object-oriented programming languages? Common OOP languages include Java, C++, Python, JavaScript, and Ruby. What is name mangling in Python? Name mangling is the transformation of attribute names (e.g., __name becomes _Pet__name) to prevent accidental access or overriding. What are the access modifiers in Java? Public (everywhere), Protected (class and subclasses), Private (class only), Default (accessible in the same package). What are the access modifiers in C++? Public, private, protected. C++ does not have a default access modifier. What is the default access modifier for class members in C++? Private. How does Python handle access control?
Python uses naming conventions (e.g., __name) but does not strictly enforce access control. What is the constructor name in Python? init (special method). How is a constructor defined in Java? Same as the class name (e.g., Pet). What is the return type of constructors in Java? No return type (void). What is the purpose of the del method in Python? It is called automatically when an object is about to be destroyed. How does Java manage object destruction? Java relies on garbage collection and provides a finalize() method for cleanup before an object is destroyed. What types of inheritance does Java support? Single Inheritance, Multilevel Inheritance, Hierarchical Inheritance. What is the diamond problem in C++? It arises in multiple inheritance when a class inherits from two classes that both derive from a common base class, leading to ambiguity. How does Python solve the diamond problem? Python uses the C3 Linearization (Method Resolution Order, MRO) algorithm to determine the order of class attribute and method searches. What is virtual inheritance in C++? It ensures that only one instance of a base class is inherited, even with multiple inheritance paths. What is the difference between method overloading and overriding? Overloading allows multiple methods with the same name but different parameters; overriding allows a subclass to provide a specific implementation of a method defined in its superclass. What is an abstract class? An abstract class cannot be instantiated directly and is meant to be inherited by subclasses, often containing abstract methods that must be implemented. What is compile-time polymorphism? Achieved by method overloading or operator overloading, decided at compile time.
In aggregation, the contained object can exist independently; in composition, it cannot. What are design patterns? Reusable solutions to common software design problems, representing best practices refined through years of software development. Name the three categories of design patterns. Creational, Structural, and Behavioral patterns. What does the Singleton Pattern ensure? That a class has only one instance and provides a single access point to it. Give a real-world analogy for the Singleton Pattern. A company's CEO, as there is only one CEO at a time. What is the Factory Pattern? A creational design pattern that provides an interface for creating objects without specifying their exact class. Provide a real-world analogy for the Factory Pattern. A car factory producing different types of cars based on the requested model. What is static binding? Binding that occurs at compile time, linking method calls directly to their definitions. What is dynamic binding? Binding that occurs at runtime, determining the method to invoke based on the actual object type. What are the performance implications of static vs dynamic binding? Static binding is faster due to compile-time resolution; dynamic binding is slightly slower due to runtime resolution. What is duck typing? A concept in dynamically typed languages where the type of an object is determined by its behavior rather than its explicit declaration. Why doesn't duck typing work in Java and C++? Because these languages use static typing, requiring explicit type declarations. What are the SOLID principles? A set of five design principles in object-oriented programming aimed at making software designs more understandable, flexible, and maintainable.
What does the Single Responsibility Principle (SRP) state? A class should have only one reason to change, meaning it should have only one job or responsibility. What is the Open/Closed Principle (OCP)? A class should be open for extension but closed for modification, allowing new functionality without altering existing code. What is the Liskov Substitution Principle (LSP)? Objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program. What does the Interface Segregation Principle (ISP) advocate? No client should be forced to depend on methods it does not use; interfaces should be split into smaller, more specific ones. What does the Dependency Inversion Principle (DIP) state? High-level modules should not depend on low-level modules; both should depend on abstractions. What is performance optimization in Object-Oriented Programming (OOP)? Techniques that improve code efficiency while maintaining flexibility, scalability, and readability. Why should unnecessary object creation be avoided? It can lead to increased memory usage and slower performance due to frequent allocations and deallocations. What is lazy initialization? Delaying the creation of an object until it is actually needed to improve startup time and reduce memory usage. What is the impact of deep inheritance hierarchies? They can make code harder to understand and may result in performance overhead due to method lookup. Why is efficient memory management important? It is critical for performance, especially in languages like C++ where low-level control over memory is possible. What is the advantage of favoring polymorphism and interfaces over inheritance? It improves flexibility and can make dynamic method dispatch more efficient. What is the purpose of compilation? To transform source code written in a high-level language into machine code or an intermediate language.
What challenges are associated with declarative programming? Performance concerns, steep learning curve, and limited tooling and support. What defines functional programming? A paradigm that treats computation as the evaluation of mathematical functions, avoiding changing state and mutable data. What are pure functions? Functions that are deterministic and have no side effects, always producing the same output for the same input. What are impure functions? Functions that have side effects, modify external state, or may produce different outputs for the same inputs. What does immutability mean in programming? Once an object is created, its state cannot be changed. What is a first-class function? A function that can be assigned to variables, passed as an argument, or returned from other functions. What is a higher-order function (HOF)? A function that takes another function as an argument or returns a function. What is inductive thinking? A reasoning process where general principles are derived from specific examples or patterns. What is the base case in recursion? The simplest scenario in recursion, often related to a boundary condition or smallest input. What is the recursive case in recursion? Defines how larger problems are broken down into simpler subproblems, often using the same function. What is referential transparency? A property where an expression can be replaced with its value without changing the program's behavior. What is eager evaluation? Expressions are evaluated as soon as they are bound to a variable, regardless of whether the result is needed later. What is lazy evaluation?
Expressions are not evaluated until their values are actually needed, improving performance by avoiding unnecessary computations. What is infix notation? The standard mathematical notation where operators are placed between operands, e.g., 3 + 5. What is prefix notation? Also known as Polish notation, where the operator is written before the operands, e.g., + 3 5. What is postfix notation? Also known as Reverse Polish notation, where the operator is placed after the operands, e.g., 3 5 +. What are the advantages of prefix and postfix notation? They eliminate the need for parentheses to dictate precedence and are easier for machines to evaluate. What is OCaml? A functional, imperative, and object-oriented programming language widely used for formal verification and compiler construction. What is function composition? The process of combining multiple functions into a single function, allowing for more concise and readable code. How can you define a composition operator in OCaml? Using the syntax: let ( % ) f g x = f (g x), where f is the outer function and g is the inner function. What is partial application? The process of fixing some arguments of a function and returning a new function with fewer parameters. What is the significance of higher-order functions? They allow code reuse, abstraction, and concise functional programming patterns.
Key operations include Return (or unit) to wrap a value into a monad and Bind (or >>=) to chain computations. What are side effects in functional programming? Side effects refer to operations that modify state or interact with the outside world, such as printing or updating a variable. Why are side effects problematic in pure functional programming? They can lead to unpredictability, state management issues, and tangled code due to global state modifications. What is pipelining in OCaml? Pipelining refers to a series of processes where the output of one function becomes the input for the next. How does the pipe operator work in OCaml? The pipe operator |>, is a right-associative operator that applies functions from left to right. What are the advantages of pipelining in OCaml? Advantages include improved readability, modular design, and efficiency in code. What is Haskell known for? Haskell is a purely functional programming language known for its purity, lazy evaluation, and strong static typing. What is lazy evaluation in Haskell? Lazy evaluation means that Haskell evaluates expressions only when needed, which can improve performance. What does immutability mean in Haskell? In Haskell, once a value is assigned to a variable, it cannot be changed, ensuring data consistency. What are list comprehensions in Haskell? List comprehensions provide a concise way to create lists using existing lists, applying transformations and filtering elements. What is pattern matching in Haskell? Pattern matching allows you to deconstruct data structures and bind variables to their components. What is the basic syntax for a list comprehension in Haskell? [ expression | element <- list, condition ] What is the significance of strong static typing in Haskell?
Strong static typing helps catch errors at compile time, reducing runtime errors and improving code reliability. What is the role of the Glasgow Haskell Compiler (GHC)? GHC is the main compiler for Haskell, allowing users to compile and run Haskell programs. What is the purpose of the Haskell Language Server (HLS)? HLS provides language support for Haskell, including features like code completion and error checking. What is the benefit of modular design in functional programming? Modular design allows each operation to be a separate function, which can be tested and modified independently. What is the primary focus of functional programming? The primary focus is on writing pure functions that avoid side effects and maintain referential transparency. What is the significance of concurrency in Haskell? Haskell's features make it well-suited for concurrent and parallel programming, which is important in modern computing. How does Haskell handle stateful computations? Stateful computations can be modeled using monads to manage state as a side effect. What does Strictness Analysis do in Haskell? It determines which function arguments can be evaluated eagerly to reduce memory usage. What is Memoization? A technique where the results of expensive function calls are cached and reused for the same inputs. What is the purpose of the map function in Haskell? It applies a function to each element of a list. When should you use foldr instead of foldl? Use foldr when processing the list from the right or with infinite lists. When should you use foldl? Use foldl when processing the list from the left with an associative and commutative function for efficiency. What is a lambda expression in Haskell? A syntax for defining anonymous functions, e.g., \x - > x + 1.