5.1 Differentiate between a syntax error and a runtime error - NSC Information Technology - Question 5 - 2020 - Paper 2
Question 5
5.1 Differentiate between a syntax error and a runtime error.
A syntax error occurs when the rules of the programming language (or an example of a programming langu... show full transcript
Worked Solution & Example Answer:5.1 Differentiate between a syntax error and a runtime error - 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, which prevents the program from running. An example is missing a semicolon. A runtime error happens when the program is executing and encounters a problem, 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. 2. Provide an indication of whether the error relates to 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 binary search can be done.
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
Variable S is not given an initial value (not initialised).
Step 5
5.3.2 Suggest TWO ways 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 to provide structure. 2. Add comments explaining the purpose of the code segments.
Step 6
5.5 Write an alternative line of Delphi code that will have the same effect as the following line of code: i := i + 1;
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
Inc(i);
Step 7
5.6.1 What do the plus (+) and minus (-) symbols represent respectively?
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 (+) indicates public members/methods, while the minus (-) indicates private members/methods.
Step 8
5.6.2 Identify TWO errors in the class diagram provided.
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
setLocation()'s parameter doesn't specify a data type. 2. getCapacity() should 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!