M&IB Devx - Code Quality

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By James Richardson
J
James Richardson
Community Contributor
Quizzes Created: 13 | Total Attempts: 10,808
Questions: 20 | Attempts: 329

SettingsSettingsSettings
M&IB Devx - Code Quality - Quiz

This is part of the DevX course assessment that will be taken by delegates before and after the programme.


Questions and Answers
  • 1. 

    Whose responsibility is it to ensure unexpected answers are handled?

    • A.

      Business Analyst

    • B.

      Lead programmer

    • C.

      End user

    • D.

      Programmer

    Correct Answer
    D. Programmer
    Explanation
    The responsibility to ensure unexpected answers are handled lies with the programmer. Programmers are responsible for developing and implementing the code that handles user inputs and processes them accordingly. They need to anticipate and account for unexpected inputs or errors in order to ensure the smooth functioning of the software or application. This involves implementing error handling mechanisms, validating user inputs, and ensuring the program can handle unexpected scenarios gracefully.

    Rate this question:

  • 2. 

    If an action is expected and unwanted , what should the programmer do?

    • A.

      Use unexpected techniques to handle the problem

    • B.

      Not worry about it - the business analyst deals with this

    • C.

      Plan for and implement the best method of removing the unwanted action

    • D.

      None of the above

    Correct Answer
    C. Plan for and implement the best method of removing the unwanted action
    Explanation
    When an action is expected but unwanted, the programmer should plan for and implement the best method of removing the unwanted action. This means the programmer should anticipate the potential issue and come up with a solution to prevent or mitigate it. Ignoring the problem or relying on others, such as a business analyst, is not a suitable approach. Instead, the programmer should take responsibility for addressing the unwanted action and finding the most effective way to eliminate it.

    Rate this question:

  • 3. 

    Why are silent discards bad?

    • A.

      Assumes an unknown scenario is ok

    • B.

      Regulatory agencies want everything recorded

    • C.

      Difficult to explain to end users

    • D.

      Can lead to unhandled errors

    Correct Answer
    A. Assumes an unknown scenario is ok
    Explanation
    Silent discards are bad because they assume that an unknown scenario is acceptable. This means that when an unexpected event or error occurs, instead of handling it properly, the system simply discards it without any notification or action. This can be problematic because it prevents proper error handling and troubleshooting, making it difficult to identify and resolve issues. Additionally, regulatory agencies require comprehensive recording of all events and errors, so silent discards can lead to non-compliance. Furthermore, it can be confusing and frustrating for end users who are unaware that their actions or errors are not being acknowledged or addressed.

    Rate this question:

  • 4. 

    What are the first steps in defensive programming?

    • A.

      Challenge, understand, eliminate, document all assumptions

    • B.

      Create data validation module for incoming data

    • C.

      Know the domain you are working in

    • D.

      Write use case for unexpected actions

    Correct Answer
    A. Challenge, understand, eliminate, document all assumptions
    Explanation
    The first steps in defensive programming involve challenging, understanding, eliminating, and documenting all assumptions. This means questioning any assumptions made during the development process, seeking to understand the reasoning behind them, and then either eliminating them if they are unnecessary or documenting them if they are valid. This helps to ensure that the code is robust and less prone to errors or vulnerabilities.

    Rate this question:

  • 5. 

    Which of the following statements is true about mutable data in a multi-threaded environment?

    • A.

      Prevent the use of locks

    • B.

      Must be locked and unlocked

    • C.

      Used only by thread safe processes

    • D.

      All of the above

    Correct Answer
    B. Must be locked and unlocked
    Explanation
    In a multi-threaded environment, mutable data refers to data that can be modified. To ensure the integrity and consistency of this data, it must be locked and unlocked. This is necessary to prevent race conditions, where multiple threads try to access and modify the data simultaneously, leading to unpredictable and incorrect results. Locking and unlocking the data ensures that only one thread can access and modify it at a time, preventing conflicts and maintaining data integrity. Therefore, the statement "Must be locked and unlocked" is true about mutable data in a multi-threaded environment.

    Rate this question:

  • 6. 

    Select TWO of the following things that software quality tools detect

    • A.

      Duplicate code

    • B.

      Non-conformance with coding standards

    • C.

      Test coverage

    • D.

      Uncommon bugs

    Correct Answer(s)
    A. Duplicate code
    B. Non-conformance with coding standards
    Explanation
    Software quality tools are designed to detect and identify issues in software development. Duplicate code is a common problem that can lead to inefficiency, maintenance difficulties, and increased risk of bugs. Non-conformance with coding standards refers to violations of established guidelines, which can affect readability, maintainability, and overall quality of the code. Test coverage is another important aspect that quality tools assess, ensuring that all parts of the code are thoroughly tested. Uncommon bugs, on the other hand, are not typically detected by quality tools as they are unpredictable and require thorough testing and debugging.

    Rate this question:

  • 7. 

    Which of these is a benefit of generational garbage collection?

    • A.

      The ability to have concurent deallocation of objects at once

    • B.

      The ability to optimize garbage collection performance

    • C.

      The abiltiy to manually deallocate objects

    • D.

      The ability to have pluggable garbage collection algorithms

    Correct Answer
    B. The ability to optimize garbage collection performance
    Explanation
    Generational garbage collection is a memory management technique where objects are divided into different generations based on their age. This technique allows the garbage collector to focus on the younger generations, which tend to have a higher rate of object allocation and deallocation. By prioritizing the younger generations, the garbage collector can optimize its performance by avoiding unnecessary scanning of older objects that are less likely to be garbage. This results in faster garbage collection and improved overall performance of the application.

    Rate this question:

  • 8. 

    Objects with finalizers require two garbage collection cycles to get deallocated

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Objects with finalizers require two garbage collection cycles to get deallocated. This is because when an object has a finalizer, it is not immediately eligible for garbage collection after it becomes unreachable. Instead, it goes through a process called finalization, where the finalizer method is executed. After the finalizer method completes, the object becomes eligible for garbage collection, but it is not immediately deallocated. It requires another garbage collection cycle to actually deallocate the object from memory.

    Rate this question:

  • 9. 

    Adding more resources to a single node in the system is called…

    • A.

      Vertical scaling

    • B.

      Horizontal scaling

    • C.

      Continuous deployment

    • D.

      Pluggalble architeture

    Correct Answer
    A. Vertical scaling
    Explanation
    Vertical scaling refers to the process of adding more resources, such as CPU, memory, or storage, to a single node in a system. This allows the node to handle increased workloads and improve performance. It is a common approach to scaling up a system when there is a need for more capacity. Unlike horizontal scaling, which involves adding more nodes to distribute the workload, vertical scaling focuses on increasing the capabilities of a single node.

    Rate this question:

  • 10. 

    Mutable objects may be bad for performance in what way?

    • A.

      They are more difficult to garbage collect

    • B.

      They require more memory than immutable objects

    • C.

      They require making more frequent defensive copies

    • D.

      They generate more network traffic

    Correct Answer
    C. They require making more frequent defensive copies
    Explanation
    Mutable objects may be bad for performance because they require making more frequent defensive copies. Defensive copying is a technique used to prevent unwanted changes to an object by creating a separate copy of it. In the case of mutable objects, if defensive copies are not made when passing the object to different parts of the code, any modification made to the object can affect its original state. This can lead to unexpected behavior and bugs, as well as potentially impacting performance due to the additional overhead of creating and managing these copies.

    Rate this question:

  • 11. 

    Benchmarking is a critical component of performance tuning

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Benchmarking is a critical component of performance tuning because it allows for the comparison of a system's performance against a standard or competitor. By conducting benchmark tests, organizations can identify areas where their performance falls short and make necessary improvements. Benchmarking helps in setting performance goals, evaluating the effectiveness of changes made, and ensuring that the system is optimized for optimal performance. Therefore, it is true that benchmarking is a critical component of performance tuning.

    Rate this question:

  • 12. 

     In general, code performance is more important than good design

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    This statement is false. While code performance is important, it is not more important than good design. Good design ensures that the code is organized, modular, and maintainable, making it easier to understand and modify in the future. It also helps in reducing bugs and improving code quality. Code performance, on the other hand, focuses on optimizing the code to run efficiently and quickly. Both good design and code performance are important factors in software development, but good design is crucial for long-term success and maintainability.

    Rate this question:

  • 13. 

    Code quality tools remove the need for programmers is visually inspect code.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Code quality tools do not remove the need for programmers to visually inspect code. While code quality tools can help identify potential issues and improve the overall quality of code, they cannot completely replace the need for human inspection. Programmers still need to review and understand the code to ensure its correctness, readability, and adherence to coding standards. Therefore, the statement is false.

    Rate this question:

  • 14. 

    Which term best describes the future cost of design tradeoffs to meet short-term goals

    • A.

      Code smell

    • B.

      Optimization

    • C.

      Design pattern

    • D.

      Technical debt

    Correct Answer
    D. Technical debt
    Explanation
    Technical debt refers to the future cost that arises from taking shortcuts or making tradeoffs in the design and development process to meet short-term goals. It is similar to financial debt, where the interest accumulates over time and needs to be paid off eventually. In the context of software development, technical debt can result in increased maintenance costs, decreased productivity, and reduced flexibility in the future. Therefore, technical debt is the term that best describes the future cost of design tradeoffs to meet short-term goals.

    Rate this question:

  • 15. 

     If an exception is caught and rethrown logging is not necessary

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    If an exception is caught and rethrown, it is still necessary to log the exception. Catching and rethrowing an exception means that the exception is caught at one point in the code and then rethrown to be caught at a higher level. Logging the exception allows for better error tracking and debugging, as it provides information about where the exception occurred and what caused it. Therefore, it is important to log the exception even if it is caught and rethrown.

    Rate this question:

  • 16. 

    Maps or Dictionaries are best under which circumstance?

    • A.

      Fast iteration is needed

    • B.

      Order of data is important

    • C.

      Random access is needed

    • D.

      Small datasets are in use

    Correct Answer
    C. Random access is needed
    Explanation
    Random access is needed when there is a requirement to quickly access and retrieve specific elements from a data structure, without the need to iterate through the entire structure. In the case of Maps or Dictionaries, random access allows for efficient lookup and retrieval of values based on their associated keys. This is particularly useful when there is a need to access specific data elements in no particular order, making Maps or Dictionaries the best choice in such circumstances.

    Rate this question:

  • 17. 

    Select TWO of the following which are disadvantages of inserting timing calling into code

    • A.

      They are inconvenient for developers to use

    • B.

      They do not measure actual CPU time

    • C.

      They require an application to be rebuilt

    • D.

      They only work well in production

    Correct Answer(s)
    B. They do not measure actual CPU time
    C. They require an application to be rebuilt
    Explanation
    Inserting timing calls into code has two disadvantages: it does not measure actual CPU time and it requires an application to be rebuilt. Timing calls may not accurately measure the actual CPU time because they only measure the time taken by the specific code being timed, not taking into account other processes or system overhead. Additionally, inserting timing calls requires modifying the code and rebuilding the application, which can be inconvenient and time-consuming for developers.

    Rate this question:

  • 18. 

    A 2x speedup of a method invocation should always be considered valuable

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    A 2x speedup of a method invocation should not always be considered valuable because it depends on the specific context and requirements of the application. While faster execution can be beneficial in many cases, there may be situations where speed is not the highest priority. For example, if the method is rarely used or if the performance gain is negligible compared to the effort required to achieve it, the value of the speedup may be limited. Additionally, optimizing for speed can sometimes lead to trade-offs in other areas such as code complexity or maintainability.

    Rate this question:

  • 19. 

    A disadvantage of Sonar is its lack of configurability

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Sonar actually offers a high level of configurability, which allows users to customize and adjust its settings to meet their specific needs. This configurability is one of the advantages of Sonar, as it enables users to tailor the system to their unique requirements and optimize its performance. Therefore, the statement that Sonar lacks configurability is false.

    Rate this question:

  • 20. 

    Select three of the following that are true when developing software logging:

    • A.

      An overhead

    • B.

      Required

    • C.

      Expensive

    • D.

      All log messages are displayed

    Correct Answer(s)
    A. An overhead
    B. Required
    C. Expensive
    Explanation
    When developing software logging, it is true that logging can introduce overhead to the system, as it requires additional resources to capture and store log messages. Logging is also often considered a required practice in software development, as it helps in troubleshooting and debugging. However, logging can be expensive in terms of storage and processing costs, especially when dealing with large-scale applications. It is not true that all log messages are displayed, as log levels and filters can be implemented to control which messages are shown.

    Rate this question:

Related Topics

Back to Top Back to top
Advertisement