5.1 There are many types of errors that can occur in software development - NSC Information Technology - Question 5 - 2020 - Paper 2
Question 5
5.1 There are many types of errors that can occur in software development.
5.1.1 Differentiate between a syntax error and a runtime error.
A syntax error occurs wh... show full transcript
Worked Solution & Example Answer:5.1 There are many types of errors that can occur in software development - NSC Information Technology - Question 5 - 2020 - Paper 2
Step 1
5.1.1 Differentiate between a syntax error and a runtime error.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
A syntax error occurs when the rules of the programming language are broken, causing the program to not compile or run. Examples include missing semicolons or misused keywords.
In contrast, a runtime error arises during the execution of the program, when the interpreter encounters a problem, such as dividing by zero or accessing an out-of-bounds array element.
Step 2
5.1.2 Give TWO guidelines on how a programmer can construct useful error messages.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Provide clear and understandable explanations of the error that occurred, ensuring the user knows exactly what went wrong.
Indicate potential solutions or troubleshooting steps to help the user resolve the issue or to guide them towards correcting the data input.
Step 3
5.2 What is the prerequisite for an array to be searched when using the binary search algorithm?
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The array needs to be sorted in ascending order before applying the binary search algorithm.
Step 4
5.3.1 Give a possible reason for this unexpected result.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The variable S was not initialized to a starting value before the loop began. This means that its initial value could be undefined, leading to unexpected results.
Step 5
5.3.2 Suggest TWO ways in which to improve the code of the novice programmer to be more readable.
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Initialize the variable S before the loop begins to ensure clear starting conditions: S := 0;.
Add comments to explain the purpose of the loop and what the program is intended to achieve, enhancing readability for other programmers.
Step 6
5.4 Draw the following incomplete trace table into your ANSWER BOOK.
97%
121 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Please refer to a separate section for the flowchart to complete this trace table step by step.
Step 7
5.5 Write an alternative line of Delphi code that will have the same effect as the following line of code: i := i + 1;
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
You can use the increment operator instead: Inc(i);.
Step 8
5.6.1 What do the plus (+) and minus (-) symbols represent respectively?
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The plus (+) symbol indicates public members, methods, or attributes, while the minus (-) symbol denotes private members, methods, or attributes.
Step 9
5.6.2 Identify TWO errors in the class diagram provided.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The setLocation() method's parameter does not specify a data type.
The getCapacity() method should return an integer data type.
Step 10
5.6.3 Identify an auxiliary method in the class diagram provided.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The method toString() serves as an auxiliary method, typically used to provide a string representation of the object.