Q.1 Which of the following is the primary purpose of debugging?
To optimize code performance
To find and fix errors in the code
To write new features
To document the code
Explanation - Debugging is the process of identifying, analyzing, and fixing errors or bugs in a program to ensure it runs correctly.
Correct answer is: To find and fix errors in the code
Q.2 What type of testing is done by developers while writing code to catch errors early?
Unit testing
System testing
Acceptance testing
Regression testing
Explanation - Unit testing involves testing individual components or functions of code to ensure they work as expected, typically done by developers.
Correct answer is: Unit testing
Q.3 Which of the following is a dynamic testing technique?
Code review
Walkthrough
Black-box testing
Syntax checking
Explanation - Black-box testing involves executing the program and checking outputs against expected results, making it a dynamic testing technique.
Correct answer is: Black-box testing
Q.4 Which debugging method involves inserting extra statements into the code to trace execution?
Code inspection
Print debugging
Rubber duck debugging
Profiling
Explanation - Print debugging involves adding print statements to track the program flow and variable values, helping locate bugs.
Correct answer is: Print debugging
Q.5 What does the term 'regression testing' refer to?
Testing the system for speed
Testing code for memory leaks
Testing old functionality after changes
Testing only new modules
Explanation - Regression testing checks whether recent changes in the code have broken existing functionality.
Correct answer is: Testing old functionality after changes
Q.6 Which of the following errors can a compiler detect?
Logical errors
Syntax errors
Runtime errors
Integration errors
Explanation - Compilers check the code for syntax errors and alert the programmer if the code structure is incorrect.
Correct answer is: Syntax errors
Q.7 What type of testing is performed without knowledge of the internal code structure?
White-box testing
Black-box testing
Unit testing
Integration testing
Explanation - Black-box testing focuses on inputs and expected outputs without considering internal implementation details.
Correct answer is: Black-box testing
Q.8 Which debugging technique involves explaining code line by line to a colleague or even an inanimate object?
Code inspection
Rubber duck debugging
Print debugging
Automated testing
Explanation - Rubber duck debugging is the practice of explaining code aloud, which often helps the programmer identify errors.
Correct answer is: Rubber duck debugging
Q.9 Which of the following tools is primarily used to detect memory leaks in programs?
Profiler
Debugger
Valgrind
Compiler
Explanation - Valgrind is a tool used to detect memory management issues like leaks and invalid memory usage in programs.
Correct answer is: Valgrind
Q.10 What is the main goal of unit testing?
To test the complete software system
To identify performance bottlenecks
To validate individual components or functions
To document the codebase
Explanation - Unit testing focuses on verifying that individual functions or modules behave as expected.
Correct answer is: To validate individual components or functions
Q.11 Which type of error occurs when a program compiles successfully but produces incorrect results?
Syntax error
Logical error
Runtime error
Compilation error
Explanation - Logical errors happen when the code runs without crashing but produces wrong outputs due to flawed logic.
Correct answer is: Logical error
Q.12 Which testing type ensures that the entire system works correctly as a whole?
Unit testing
System testing
Integration testing
Acceptance testing
Explanation - System testing validates that all components of a software system function together correctly.
Correct answer is: System testing
Q.13 Which of the following is NOT a characteristic of white-box testing?
Requires knowledge of internal code structure
Tests code logic paths
Focuses only on outputs
Helps identify hidden errors
Explanation - White-box testing examines internal code structures and logic paths, not just outputs.
Correct answer is: Focuses only on outputs
Q.14 What does 'test coverage' measure?
Number of bugs found
Extent of code executed during testing
Program performance
Documentation completeness
Explanation - Test coverage measures how much of the code is exercised during testing, helping assess thoroughness.
Correct answer is: Extent of code executed during testing
Q.15 Which type of testing is often automated to check for repeated regressions?
Unit testing
Regression testing
System testing
Alpha testing
Explanation - Regression testing ensures new code changes don't break existing functionality and is often automated for efficiency.
Correct answer is: Regression testing
Q.16 What is a breakpoint in debugging?
A tool to check code style
A point where program execution is paused
A performance bottleneck
A function to reset variables
Explanation - A breakpoint allows the programmer to pause execution at a specific line to inspect program state during debugging.
Correct answer is: A point where program execution is paused
Q.17 Which of the following is an example of static testing?
Unit testing
Code review
System testing
Acceptance testing
Explanation - Static testing examines code without executing it, such as code reviews or inspections.
Correct answer is: Code review
Q.18 What is the main disadvantage of print debugging?
Cannot detect logical errors
Slows down program execution and clutters code
Requires specialized software
Cannot trace variables
Explanation - Print debugging can clutter code and slow execution because of excessive print statements, though it helps trace execution.
Correct answer is: Slows down program execution and clutters code
Q.19 Which type of testing is performed by end-users before software release?
Alpha testing
Unit testing
Beta testing
Integration testing
Explanation - Beta testing involves end-users testing the software in real-world environments before its official release.
Correct answer is: Beta testing
Q.20 Which of the following is NOT typically detected by a debugger?
Segmentation fault
Memory leaks
Logical errors
Syntax errors
Explanation - Syntax errors are detected by the compiler, not during runtime debugging.
Correct answer is: Syntax errors
Q.21 In automated testing, what is a 'test script'?
A manual testing checklist
A program that executes tests automatically
A bug report
A code documentation file
Explanation - A test script is a set of instructions executed by automated testing tools to perform tests without manual intervention.
Correct answer is: A program that executes tests automatically
Q.22 Which testing approach focuses on checking program output for given inputs without knowledge of code?
White-box testing
Black-box testing
Unit testing
Integration testing
Explanation - Black-box testing evaluates software behavior based on inputs and expected outputs, ignoring the internal code structure.
Correct answer is: Black-box testing
Q.23 What does 'profiling' a program help determine?
Syntax correctness
Memory usage and performance bottlenecks
Logical errors
Code style violations
Explanation - Profiling analyzes a program to identify performance issues and memory usage patterns.
Correct answer is: Memory usage and performance bottlenecks
Q.24 Which of the following is an advantage of automated testing?
Requires no initial setup
Can be repeated easily for regression testing
Does not need skilled testers
Always detects all bugs
Explanation - Automated tests can be rerun multiple times efficiently, especially useful for regression testing.
Correct answer is: Can be repeated easily for regression testing
Q.25 What is the purpose of 'assert statements' in debugging?
To handle exceptions
To check assumptions about program state
To measure performance
To terminate the program immediately
Explanation - Assert statements verify that certain conditions hold true during execution, helping catch logical errors early.
Correct answer is: To check assumptions about program state
