Exercises

Systematic Debugging and Error Handling Fundamentals

Learn how programmers identify, isolate, and correct software defects. This quiz covers syntax, runtime, and logic errors; reproducible test cases; breakpoints; debugger stepping commands; stack traces; watchpoints; assertions; exception handling; logging; regression searches; off-by-one errors; and cleanup with finally blocks. Questions combine practical scenarios with visual code and debugger examples.

Answer the questions below and check the explanation for each answer.

0/14 answered

  1. 1

    The code shown in the image cannot begin normal execution. What type of error does it contain?

    Question 1
  2. 2

    A valid program reads a number and divides 100 by it. If the user enters zero and the program stops with a division-by-zero message, how should the defect be classified?

  3. 3

    The image shows a program that should calculate the average of three scores. Why does it print 67.5 instead of 90?

    Question 3
  4. 4

    After reproducing a bug reliably, which action best supports systematic debugging before changing the program?

  5. 5

    What normally happens when program execution reaches an enabled breakpoint?

  6. 6

    The debugger is paused on the function call shown in the image. Which command should be used to execute the entire calculate function without pausing inside it?

    Question 6
  7. 7

    According to the stack trace in the image, in which function did the reported conversion error originate?

    Question 7
  8. 8

    During a long loop, a variable named balance changes unexpectedly. Which debugger feature can pause execution specifically when that variable is modified?

    Question 8
  9. 9

    What is the most appropriate purpose of an assertion such as assert item_count >= 0?

  10. 10

    Which exception-handling strategy is generally the most reliable?

  11. 11

    Why is structured logging usually more useful than scattered temporary print statements when diagnosing a deployed application?

  12. 12

    A regression exists somewhere among 128 ordered code revisions, and each revision can be tested as passing or failing. Which method most efficiently finds the first failing revision?

  13. 13

    The image shows a loop processing an array of length 5. Which change prevents the out-of-range access while still processing every element?

    Question 13
  14. 14

    A file is opened inside a try block. Which construct is intended for cleanup that should occur whether the operation succeeds or raises an exception?

Download the App now to have access to + 5000 free courses, exercises, certificates and lots of content without paying anything!

  • 100% free online courses from start to finish

    Thousands of online courses in video, ebooks and audiobooks.

  • More than 60 thousand free exercises

    To test your knowledge during online courses

  • Valid free Digital Certificate with QR Code

    Generated directly from your cell phone's photo gallery and sent to your email

Cursa app on the ebook screen, the video course screen and the course exercises screen, plus the course completion certificate