← All CPP Flashcard Decks

Mixed Deck — All CPP Topics Flashcards

100 cards from real CPP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 20 Mixed Deck — All CPP Topics flashcards as text
  1. What is thread starvation?

    Answer: A thread that is perpetually denied CPU time because higher-priority threads always preempt it

    Thread starvation happens when a thread never gets scheduled because other threads or high-priority tasks continuously consume CPU time.

  2. A table is in Third Normal Form (3NF) if it is in 2NF and contains no:

    Answer: Transitive dependencies

    3NF requires the table to be in 2NF and that no non-key attribute depends transitively on the primary key (i.e., no non-key → non-key dependencies).

  3. What is the difference between parallelism and concurrency?

    Answer: Concurrency is about dealing with multiple tasks at once (possibly interleaved); parallelism is executing multiple tasks simultaneously on multiple processors

    Concurrency is a design concern about structuring a program to handle multiple tasks; parallelism is physical simultaneous execution on multiple cores.

  4. Which of the following is a non-linear data structure?

    Answer: Binary Tree

    A Binary Tree is a non-linear data structure where each node has at most two children, typically referred to as the left child and the right child. Unlike linear structures like arrays, linked lists, and stacks, which arrange data sequentially, a binary tree organizes data hierarchically in a branching fashion.

  5. Which tool is commonly used for debugging in software development?

    Answer: Debugger

    A debugger is a specialized software tool specifically designed to assist programmers in the process of finding and fixing errors in their code. It provides functionalities like setting breakpoints, stepping through code execution line by line, inspecting variable values, and examining the call stack. These features make it an indispensable tool for diagnosing and resolving software defects.

  6. What is a breakpoint in debugging?

    Answer: A point where the code execution is paused

    In debugging, a breakpoint is a deliberate stopping point or pause inserted into the code by the developer. When the program's execution reaches a breakpoint, it temporarily halts, allowing the programmer to inspect the program's state, including variable values, memory contents, and the call stack, at that precise moment. This pause is crucial for understanding program flow and identifying the source of errors.

  7. What is the purpose of debugging in software development?

    Answer: To find and fix errors in the code

    Debugging is the essential process of systematically identifying, analyzing, and resolving defects or 'bugs' within a computer program. Its core purpose is to pinpoint the exact location and cause of unexpected behavior or errors in the code. Once identified, the debugger helps developers implement fixes to ensure the software operates correctly and reliably.

  8. What is the producer-consumer pattern?

    Answer: A concurrency pattern where producers add work to a shared queue and consumers process items from it

    The producer-consumer pattern decouples work generation from processing using a thread-safe buffer, enabling independent scaling of each side.

  9. What is the purpose of lazy initialization?

    Answer: Defer object creation until the first time it is actually needed

    Lazy initialization avoids expensive setup until it's necessary, improving startup time and avoiding unnecessary resource use.

  10. Which SDLC model focuses on iterative development and frequent feedback?

    Answer: Spiral

    The Spiral model is an iterative and risk-driven SDLC model that combines elements of both waterfall and prototyping models. It emphasizes repeated cycles of planning, risk analysis, engineering, and evaluation, allowing for frequent feedback and adaptation throughout the project lifecycle. This makes it suitable for complex projects where requirements may evolve.

  11. What happens during the Maintenance phase of SDLC?

    Answer: Fixing bugs and making updates

    During the Maintenance phase of SDLC, the software system is continuously monitored and supported after its deployment. This involves fixing newly discovered bugs, implementing enhancements, adapting the system to new environments or technologies, and making updates to ensure its ongoing functionality and relevance over time.

  12. A correlated subquery differs from a regular subquery in that it:

    Answer: References a column from the outer query and re-executes for each outer row

    A correlated subquery references a column from the outer query, causing it to be re-evaluated once per row of the outer query rather than once total.

  13. What is the Observer design pattern?

    Answer: A pattern defining a one-to-many dependency so that when one object changes state, all its dependents are notified automatically

    The Observer pattern implements publish-subscribe, where a subject maintains a list of observers and notifies them of state changes.

  14. What is the difference between unit testing and integration testing?

    Answer: Unit testing tests individual code units, while integration testing tests the interaction between modules

    Unit testing focuses on verifying the smallest testable parts of an application, such as individual functions or methods, in isolation to ensure they work correctly. In contrast, integration testing examines the interactions and interfaces between multiple integrated software modules or components, ensuring they work together seamlessly. This distinction addresses different scopes of functionality and potential defect areas.

  15. What is the purpose of regression testing?

    Answer: To ensure that code changes do not break existing functionality

    Regression testing is a critical type of software testing performed after code changes, such as bug fixes, new features, or refactoring, have been implemented. Its primary purpose is to ensure that these modifications have not inadvertently introduced new defects or caused existing, previously working functionality to break. This helps maintain the stability and quality of the software over time.

  16. What is garbage collection in a managed runtime environment?

    Answer: Automatic identification and freeing of memory no longer referenced by the application

    Garbage collection automates memory reclamation by detecting objects with no live references and freeing their memory.

  17. What is a 'static' method in OOP?

    Answer: A method belonging to the class rather than any instance

    Static methods belong to the class itself and can be called without creating an instance of the class.

  18. What is the principle behind 'defense in depth' in security?

    Answer: Using multiple independent security controls so that if one layer is breached, others still protect the system

    Defense in depth layers security controls (authentication, authorization, encryption, firewalls, monitoring) so no single failure exposes the entire system.

  19. In the CAP theorem for distributed databases, which two properties can be simultaneously guaranteed during a network partition?

    Answer: Consistency and Partition Tolerance, or Availability and Partition Tolerance — but not all three

    The CAP theorem states that during a network partition, a distributed system can guarantee either Consistency or Availability but not both; Partition Tolerance is mandatory in distributed systems.

  20. What is exception chaining (wrapping)?

    Answer: Catching an exception and re-throwing it wrapped in a new exception to preserve the original cause

    Exception chaining preserves the root cause by embedding the original exception as the 'cause' of a new higher-level exception.