Class 10: Chapter 3 Short Question Answers (SRQs)

Programming Fundamentals – Unit Testing, Arrays vs Lists, Debugging Techniques.

Back to Chapter 3 MCQs

Class 10 Chapter 3: Short Question Answers (SRQs)

4) How is unit testing used when adding a function to an already written program?

Answer:

Unit testing helps verify that a new function works properly without breaking the existing code. When adding a new function, you write small tests (called unit tests) to check each part of that function. If the tests pass, it means the function behaves as expected. This saves time and helps detect bugs early in the development process.

5) Enlist 3 key differences between Array and List.

Answer:

FeatureList (JavaScript Array)Array (TypedArray)
Data TypesCan store mixed types (numbers, strings, objects)Stores only one data type (typed: int, float, etc.)
SpeedSlower for large datasets or numerical computationFaster for numerical operations (especially in WebGL, etc.)
Memory UsageHigher memory usage due to dynamic typingOptimized, lower memory footprint
UsageGeneral-purpose list operationsBest for numerical and performance-critical operations
Module NeededBuilt-in (Array)Built-in (TypedArray, no extra modules)

6) How are breakpoints useful in debugging? Elaborate with the help of an example.

Answer:

Breakpoints pause the code execution at a specific line while running, allowing the programmer to inspect variable values and program flow. This helps find where errors occur.

Example: Suppose a loop isn’t giving the correct output. You can set a breakpoint inside the loop and run the program step-by-step. This way, you can observe whether the loop works correctly and check the value of each variable during each iteration.