HomeSubjectsUniversityBlogAbout

Debugging, Testing & Optimization

Topic in Programming

210 total MCQsShowing 30 with explanations10 Easy10 Medium10 Hard

About This Topic

Debugging is finding and fixing the cause of wrong program behaviour, testing checks code against expected results, and optimisation improves efficiency. Questions ask about breakpoints, stepping, logging and stack traces, and about unit, integration and regression tests. Know the red-green-refactor cycle of test-driven development, test doubles such as stubs versus mocks, and verification (building the product right) versus validation (building the right product). Code quality items cover static analysis and linters, profiling to find bottlenecks, and code coverage. Advanced questions touch on mutation testing, taint analysis for security, and formal verification compared with testing.

Below are 30 practice questions from a pool of 210 Debugging, Testing & Optimization MCQs, one of 16 topics in Programming. Each shows the correct answer with an explanation; when you are ready, take a timed quiz to test recall under exam conditions.

Practice Questions

Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.

Debugging, Testing & OptimizationEasy

Q1. What is debugging?

  1. A.Compiling code into machine language
  2. B.Writing new source code from scratch
  3. C.Finding and fixing errors in a program✓ Correct
  4. D.Running automated tests on the code

Explanation

Debugging is the systematic process of identifying, analyzing, and removing errors from software.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q2. What is a test case?

  1. A.A debug tool for stepping through code line by line
  2. B.A set of inputs and expected results for verification✓ Correct
  3. C.A code review process performed by team members
  4. D.A programming language for writing test scripts

Explanation

A test case defines inputs, actions, and expected outcomes to verify specific behavior.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q3. What is print/console debugging?

  1. A.Using print statements to display values and flow✓ Correct
  2. B.An automated process for finding and fixing bugs
  3. C.A graphical user interface tool for visual debugging
  4. D.Professional debugging using specialized IDE tools

Explanation

Print debugging uses output statements to trace variable values and execution flow.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q4. What is a breakpoint?

  1. A.An error in the source code of the program
  2. B.A marker where the debugger pauses for inspection✓ Correct
  3. C.An exit point from a loop during execution flow
  4. D.The end of a function where control is returned

Explanation

A breakpoint is a point where the debugger pauses execution for variable inspection.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q5. What is a unit test?

  1. A.A user acceptance test for final validation
  2. B.Testing the entire application end to end
  3. C.A test verifying a single isolated code unit✓ Correct
  4. D.A performance test measuring execution speed

Explanation

A unit test tests an individual function or method in isolation.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q6. What is a bug?

  1. A.A type of variable storing debug data
  2. B.A feature that works as intended
  3. C.A function used for error handling
  4. D.An error or flaw causing wrong behavior✓ Correct

Explanation

A bug is a defect that causes incorrect or unexpected results.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q7. What does the term 'step over' mean in debugging?

  1. A.Execute current line and move to next without entering calls✓ Correct
  2. B.Skip the entire program execution completely
  3. C.Jump directly to the end of the current function body
  4. D.Restart the debugging session from the very beginning

Explanation

Step over executes the current line completely and stops at the next line in the current function.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q8. What is a logic error?

  1. A.An error where program runs but produces incorrect results✓ Correct
  2. B.A syntax mistake caught during code compilation by compiler
  3. C.A type error from assigning incompatible values to variables
  4. D.A compile error that prevents the program from being built

Explanation

A logic error produces wrong results because the algorithm or logic is incorrect.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q9. What is a syntax error?

  1. A.A logic mistake producing incorrect program results
  2. B.A runtime error that occurs during program execution
  3. C.A design flaw in the overall application architecture
  4. D.A violation of language grammar rules at compile time✓ Correct

Explanation

A syntax error occurs when code doesn't conform to the language's grammar rules.

Report an error in this question

Debugging, Testing & OptimizationEasy

Q10. What is the purpose of an assertion?

  1. A.To create a new variable in the current scope of code
  2. B.To import a module from an external library into the file
  3. C.To define a new function with parameters and return type
  4. D.To verify a condition is true and fail with message if not✓ Correct

Explanation

An assertion checks a condition and throws an error if false, validating assumptions.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q11. What is code coverage?

  1. A.How much source code has been written in total
  2. B.The percentage of code lines executed during testing✓ Correct
  3. C.A code review tool for examining code quality metrics
  4. D.A security measure for protecting source code files

Explanation

Code coverage measures what percentage of source code is exercised by the test suite.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q12. What is Test-Driven Development (TDD)?

  1. A.A deployment strategy for releasing code to production
  2. B.Testing code only after all development is complete
  3. C.Writing tests before code to drive the design process✓ Correct
  4. D.A debugging technique for finding runtime exceptions

Explanation

TDD follows: write a failing test, write minimal code to pass it, then refactor.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q13. What is the difference between black-box and white-box testing?

  1. A.There is no meaningful difference between the two testing approaches
  2. B.Black-box tests functionality without code; white-box tests internals✓ Correct
  3. C.White-box testing is fully automated while black-box is manual
  4. D.Black-box testing is always better than white-box in every case

Explanation

Black-box validates behavior based on specifications. White-box examines internal code structure and logic paths.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q14. What is a memory profiler?

  1. A.A physical RAM module installed in the computer
  2. B.A tool monitoring memory usage and detecting leaks✓ Correct
  3. C.A compiler for translating source code to binaries
  4. D.A debugger for stepping through code line by line

Explanation

A memory profiler tracks memory allocations, usage patterns, and identifies memory leaks.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q15. What is the difference between stubs and mocks?

  1. A.Mocks are simpler and provide less functionality than stubs do
  2. B.They are identical testing concepts with no differences at all
  3. C.Stubs are more complex to implement than mocks in every case
  4. D.Stubs provide predefined responses; mocks also verify interactions✓ Correct

Explanation

Stubs return predefined data. Mocks also verify that they were called correctly.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q16. What is integration testing?

  1. A.Testing interaction between multiple components together✓ Correct
  2. B.Testing the user interface for visual correctness
  3. C.Testing individual functions in complete isolation
  4. D.Testing performance under heavy load conditions

Explanation

Integration testing verifies that different modules work correctly together.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q17. What is a mock object in testing?

  1. A.A simulated object mimicking real behavior for tests✓ Correct
  2. B.A real database connection used in production
  3. C.A randomly generated object with unpredictable state
  4. D.A deleted object that has been garbage collected

Explanation

A mock simulates the behavior of real dependencies, allowing isolated testing.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q18. What is the difference between manual and automated testing?

  1. A.There is no practical difference between the two testing methods
  2. B.Manual testing is done by humans; automated uses scripts and tools✓ Correct
  3. C.Automated testing is less reliable than manual in every case
  4. D.Manual testing is faster than automated testing for all suites

Explanation

Manual testing involves humans executing test cases. Automated testing uses scripts and tools for speed and repeatability.

Report an error in this question

Debugging, Testing & OptimizationHard

Q19. What is property-based testing?

  1. A.Specifying invariants that hold for all generated inputs✓ Correct
  2. B.Testing object properties for correct values and types
  3. C.Testing CSS properties for correct visual rendering
  4. D.Testing configuration properties for application behavior

Explanation

Property-based testing generates random inputs to verify that specified properties always hold.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q20. What is regression testing?

  1. A.Testing for performance regression and slower execution
  2. B.Re-running tests after changes to ensure nothing broke✓ Correct
  3. C.Testing only brand new features and functionality
  4. D.Testing backward compatibility with previous versions

Explanation

Regression testing re-executes existing tests to ensure changes haven't introduced new bugs.

Report an error in this question

Debugging, Testing & OptimizationMedium

Q21. What is profiling in software optimization?

  1. A.Writing documentation for the application source code
  2. B.Analyzing execution to identify performance bottlenecks✓ Correct
  3. C.Formatting code according to style guide conventions
  4. D.Creating user profiles for application personalization

Explanation

Profiling measures execution characteristics to identify performance bottlenecks.

Report an error in this question

Debugging, Testing & OptimizationHard

Q22. What is fuzzing?

  1. A.Making code intentionally unclear and hard to understand
  2. B.Feeding random or malformed data to find vulnerabilities✓ Correct
  3. C.A string operation for making text fuzzy and unreadable
  4. D.A sorting technique that introduces randomness into order

Explanation

Fuzzing generates random or semi-random inputs to find crashes, security holes, and unexpected behavior.

Report an error in this question

Debugging, Testing & OptimizationHard

Q23. What is mutation testing?

  1. A.Testing DNA sequences for mutations in bioinformatics apps
  2. B.Introducing small code changes to check if tests catch them✓ Correct
  3. C.Testing genetic algorithms for correct evolution behavior
  4. D.Testing code changes for backward compatibility with old code

Explanation

Mutation testing inserts small changes into source code and checks if the test suite detects them.

Report an error in this question

Debugging, Testing & OptimizationHard

Q24. What is the difference between static and dynamic analysis?

  1. A.Dynamic analysis is performed before compilation of the source code
  2. B.Static examines code without executing; dynamic examines during execution✓ Correct
  3. C.There is no meaningful difference between the two analysis approaches
  4. D.Static analysis is performed at runtime while the program is executing

Explanation

Static analysis inspects source code without running it. Dynamic analysis examines behavior during execution.

Report an error in this question

Debugging, Testing & OptimizationHard

Q25. What is a flame graph in performance analysis?

  1. A.An error graph displaying exception frequency over time
  2. B.A fire hazard visualization for safety monitoring apps
  3. C.A visualization of call stacks showing CPU time by code path✓ Correct
  4. D.A heat map showing temperature distribution across hardware

Explanation

A flame graph visualizes sampled stack traces, quickly revealing performance hotspots.

Report an error in this question

Debugging, Testing & OptimizationHard

Q26. What is chaos engineering?

  1. A.Random testing with no specific goals or expected outcomes
  2. B.Unstructured development without any planning or methods
  3. C.Creating intentionally buggy software for entertainment
  4. D.Intentionally introducing failures to test system resilience✓ Correct

Explanation

Chaos engineering deliberately injects failures into production systems to verify they can withstand disruptions.

Report an error in this question

Debugging, Testing & OptimizationHard

Q27. What is taint analysis?

  1. A.Analyzing memory allocation patterns for optimization purposes
  2. B.Tracking untrusted input flow to find security vulnerabilities✓ Correct
  3. C.Checking code for bugs using standard debugging tools
  4. D.Formatting code according to standard style guide conventions

Explanation

Taint analysis tracks data from untrusted sources to detect if it reaches sensitive operations without sanitization.

Report an error in this question

Debugging, Testing & OptimizationHard

Q28. What is the difference between correctness testing and performance testing?

  1. A.They are exactly the same type of testing with no differences
  2. B.Correctness verifies behavior; performance measures speed and resources✓ Correct
  3. C.Correctness testing measures execution speed like performance does
  4. D.Performance testing checks for bugs just like correctness testing

Explanation

Correctness testing ensures correct results. Performance testing measures response times and resource utilization under load.

Report an error in this question

Debugging, Testing & OptimizationHard

Q29. What is symbolic execution?

  1. A.Executing code with special symbol characters as input data
  2. B.Executing code with symbolic values to explore all possible paths✓ Correct
  3. C.A debugging mode that shows variable names instead of values
  4. D.Running code with special characters to test encoding correctness

Explanation

Symbolic execution uses symbolic inputs to explore all feasible execution paths, generating inputs that trigger specific paths or bugs.

Report an error in this question

Debugging, Testing & OptimizationHard

Q30. What is the difference between benchmarking and profiling?

  1. A.They are identical performance analysis methods with no differences
  2. B.Benchmarking measures overall metrics; profiling identifies bottlenecks✓ Correct
  3. C.Profiling gives overall performance metrics; benchmarking is specific
  4. D.Benchmarking provides more detailed analysis than profiling overall

Explanation

Benchmarking measures overall performance for comparison. Profiling breaks down performance per function to locate bottlenecks.

Report an error in this question

Ready to test yourself on Debugging, Testing & Optimization?

Take a timed quiz drawn from 210+ questions on this topic. No signup required — your progress saves in your browser.

Start Debugging, Testing & Optimization Quiz