




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A practice exam focused on software maintainability, covering key concepts from iso 25010 and best practices in c programming. It includes questions and detailed explanations on topics such as technical debt, code refactoring, cyclomatic complexity, and the single responsibility principle. This resource is designed to help software developers and students prepare for certification and improve their understanding of software quality and maintainability. The exam questions cover a range of topics, including corrective, adaptive, and perfective maintenance, as well as preventive measures like refactoring and code review techniques. The document also touches on the importance of code clarity, consistent formatting, and effective commenting for long-term maintainability.
Typology: Exams
1 / 113
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which ISO 25010 quality characteristic directly describes the ease with which a software system can be modified to fix defects? A) Reliability B) Maintainability C) Portability D) Security Answer: B Explanation: Maintainability in ISO 25010 covers the effort required to correct faults, improve performance, or adapt the software. Question 2. A software project that repeatedly incurs high costs due to frequent bug‑fixes most likely suffers from a deficiency in which attribute? A) Testability B) Maintainability C) Usability D) Compatibility Answer: B Explanation: Low maintainability leads to expensive corrective maintenance, driving up overall costs. Question 3. Which type of maintenance is performed when a program is updated to run on a newer operating system version?
A) Corrective B) Adaptive C) Perfective D) Preventive Answer: B Explanation: Adaptive maintenance modifies the system to cope with changes in its environment, such as OS upgrades. Question 4. Adding a new feature based on user feedback is an example of: A) Corrective maintenance B) Adaptive maintenance C) Perfective maintenance D) Preventive maintenance Answer: C Explanation: Perfective maintenance enhances functionality or performance in response to stakeholder needs. Question 5. Refactoring code to improve its structure without changing behavior is primarily classified as: A) Corrective maintenance B) Adaptive maintenance
Answer: C Explanation: Interest is the extra effort required to maintain or extend code that was hastily written. Question 8. In C, which naming convention improves readability by indicating that a macro is a constant? A) lower_case_with_underscores B) CamelCase C) ALL_CAPS_WITH_UNDERSCORES D) kebab-case Answer: C Explanation: Macros are traditionally written in all caps with underscores to distinguish them from variables. Question 9. Which of the following is a recommended practice for variable declaration in C to enhance maintainability? A) Declare all variables at the top of the file. B) Declare variables as global whenever possible. C) Declare variables close to their first use. D) Use single‑letter names for all variables. Answer: C
Explanation: Declaring variables near their first use reduces their lifespan and improves code clarity. Question 10. What is the primary purpose of include guards in header files? A) To improve compilation speed. B) To prevent multiple definitions of the same symbols. C) To enforce naming conventions. D) To generate documentation automatically. Answer: B Explanation: Include guards avoid duplicate inclusion of a header, preventing redefinition errors. Question 11. Which formatting style reduces the likelihood of “spaghetti code” in C? A) Placing all code in a single file. B) Using consistent indentation and brace placement. C) Omitting whitespace between operators. D) Writing long chained statements without line breaks. Answer: B Explanation: Consistent formatting makes the logical structure visible, aiding readability.
B) Improving testability and understandability. C) Enhancing security encryption. D) Increasing runtime speed. Answer: B Explanation: Lower complexity makes code easier to test, understand, and maintain. Question 15. According to the Single Responsibility Principle, a function should: A) Perform all tasks related to a module. B) Execute a single well‑defined operation. C) Contain at most ten lines of code. D) Return multiple data types. Answer: B Explanation: SRP dictates that each unit (function, module) should have one responsibility. Question 16. The “DRY” principle advises developers to: A) Write code without any comments. B) Duplicate code to avoid abstraction overhead. C) Eliminate redundant code by reusing existing logic. D) Use global variables for shared data.
Answer: C Explanation: “Don’t Repeat Yourself” encourages reuse to avoid maintenance problems caused by duplication. Question 17. Which construct in C is the preferred way to replace magic numbers? A) Inline assembly. B) #define or const variables with meaningful names. C) Hard‑coded literals in every function. D) Using enum values only for loop counters. Answer: B Explanation: Named constants make the purpose of values clear and simplify future changes. Question 18. High coupling between two C modules typically results in: A) Easier unit testing of each module. B) Greater flexibility when swapping implementations. C) Increased risk of cascading changes. D) Improved compile‑time performance. Answer: C Explanation: Tight coupling means changes in one module may require changes in the other, hurting maintainability.
Question 21. Which of the following is a “code smell” that suggests a need for refactoring? A) A function with a single return statement. B) A header file that includes only one other header. C) A function longer than 200 lines. D) A variable declared as const. Answer: C Explanation: Very long functions are hard to understand and maintain, indicating a smell. Question 22. Pair programming is an example of which code review technique? A) Formal inspection B) Walkthrough C) Pair review (continuous review) D) Automated static analysis Answer: C Explanation: Pair programming involves two developers reviewing each other’s code in real time. Question 23. Which item on a maintainability checklist would most directly address the risk of “large, monolithic functions”? A) Verify all variables are declared at file scope.
B) Ensure each function does not exceed a predefined line count. C) Confirm all header files have include guards. D) Check that all magic numbers are replaced by constants. Answer: B Explanation: Limiting function size reduces complexity and improves maintainability. Question 24. The “Extract Function” refactoring pattern is best applied when: A) A function contains duplicated logic that can be shared. B) A function calls too many external libraries. C/ A function has many global variables. D) A function’s name is too long. Answer: A Explanation: Extracting common code into its own function eliminates duplication and clarifies intent. Question 25. In Test‑Driven Development, the “Red‑Green‑Refactor” cycle begins with: A) Writing a passing test. B) Refactoring existing code. C) Writing a failing test.
Explanation: Tests verify that refactoring does not alter external behavior. Question 28. An “iterative refactoring” approach emphasizes: A) Making many changes at once to reduce overhead. B) Applying small, incremental changes with frequent verification. C) Refactoring only after a major release. D) Refactoring only code that contains bugs. Answer: B Explanation: Small, controlled changes minimize risk and simplify rollback if needed. Question 29. Reproducible builds are important for maintainability because they: A) Reduce the size of the executable. B) Ensure that the same source always yields the same binary, simplifying debugging. C) Allow developers to use any compiler version. D) Enable automatic generation of documentation. Answer: B Explanation: Consistent builds make it easier to trace issues and verify that changes are the only differences.
Question 30. Treating all compiler warnings as errors primarily helps to: A) Increase execution speed. B) Reduce runtime memory usage. C) Enforce higher code quality and early defect detection. D) Simplify the build script. Answer: C Explanation: Warnings often point to questionable code; treating them as errors forces correction. Question 31. Which of the following best describes “unit testing” in C? A) Testing the entire application as a whole. B) Testing individual functions or modules in isolation. C) Performing manual UI tests. D) Running performance benchmarks. Answer: B Explanation: Unit tests focus on a single function/module, verifying its behavior independently. Question 32. High test coverage is considered an indirect indicator of: A) Faster execution time. B) Better maintainability.
Answer: B Explanation: Cohesion measures how closely related the responsibilities within a module are; high cohesion is desirable. Question 35. Which of the following is NOT a type of software maintenance? A) Corrective B) Adaptive C) Predictive D) Preventive Answer: C Explanation: Predictive maintenance is not listed in the standard maintenance categories; the correct term is “Perfective”. Question 36. When a function’s cyclomatic complexity reaches 15, which action is most appropriate? A) Increase the function’s size to improve readability. B) Refactor the function to reduce decision points. C) Add more comments to explain each branch. D) Convert the function to assembly language. Answer: B Explanation: High complexity suggests the function is hard to understand and test; refactoring reduces complexity.
Question 37. Which of the following is the best reason to avoid global variables in maintainable C code? A) They improve execution speed. B) They increase coupling and reduce modularity. C) They simplify memory management. D) They enable easier unit testing. Answer: B Explanation: Global variables create hidden dependencies, making code harder to understand and modify. Question 38. In a header file, the pattern #ifndef MY_HEADER_H … #define MY_HEADER_H … #endif is used to: A) Optimize compilation time. B) Prevent multiple inclusion of the same header. C) Declare external variables. D) Generate documentation automatically. Answer: B Explanation: This is the classic include‑guard idiom. Question 39. Which metric specifically measures the amount of data exchanged between modules?
C) Memory usage. D. Compatibility with older compilers. Answer: B Explanation: switch makes multi‑branch logic clearer and easier to modify. Question 42. Which of the following is a recommended practice when using #define macros for constants? A) Use all lower‑case names. B) Enclose macro definitions in parentheses. C) Define macros inside function bodies. D) Allow macros to evaluate side effects. Answer: B Explanation: Parenthesizing macro bodies prevents unexpected operator precedence issues. Question 43. During a code review, a reviewer notices that a function returns multiple error codes using magic numbers (e.g., - 1, - 2). The best improvement is: A) Replace the numbers with an enum that gives each error a meaningful name. B) Change the return type to void. C) Remove all error handling. D) Convert the function to a macro.
Answer: A Explanation: An enum provides self‑documenting error codes, enhancing readability and maintainability. Question 44. Which of the following best describes “cohesion” in the context of C modules? A) The number of external libraries a module depends on. B) The degree to which elements within a module belong together. C) The amount of whitespace used in the source file. D) The frequency of compiler warnings. Answer: B Explanation: Cohesion measures how related the responsibilities inside a module are; high cohesion is desirable. Question 45. A developer wants to ensure that any change to a public API triggers a rebuild of dependent modules. Which build practice helps achieve this? A) Incremental compilation without dependency tracking. B) Using makefile rules that list header files as prerequisites. C) Compiling all source files in a single command. D) Disabling the compiler’s optimization flags. Answer: B