5.1 Differentiating between a syntax error and a runtime error is crucial in programming:
A syntax error occurs when the rules of the programming language are violated - NSC Information Technology - Question 5 - 2020 - Paper 2
Question 5
5.1 Differentiating between a syntax error and a runtime error is crucial in programming:
A syntax error occurs when the rules of the programming language are viola... show full transcript
Worked Solution & Example Answer:5.1 Differentiating between a syntax error and a runtime error is crucial in programming:
A syntax error occurs when the rules of the programming language are violated - 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 violated, preventing the program from compiling. A runtime error happens during program execution due to unforeseen issues, like dividing by zero.
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
Explain the error in understandable terms to the user.
Provide an indication whether the error is due to a problem with the software or hardware.
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 before a binary search can be executed.
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, causing it to have a garbage value before being used in the loop.
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
Indentation should be used to clearly present the structure of the code.
Comments should be added to explain the purpose of variables and the logic in the code.
Step 6
5.5 Write an alternative line of Delphi code.
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
An alternative line of code is Inc(i);.
Step 7
5.6.1 What do the plus (+) and minus (-) symbols represent?
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
The plus (+) symbol indicates public members, while the minus (-) indicates private members.
Step 8
5.6.2 Identify TWO errors in the class diagram.
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 'setLocation()' method’s parameter does not specify a data type.
The 'getCapacity()' method should explicitly return an integer data type.
Step 9
5.6.3 Identify an auxiliary method 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
'toString()' is an auxiliary method in the class diagram.