Photo AI

5.1 Differentiate between a syntax error and a runtime error - NSC Information Technology - Question 5 - 2020 - Paper 2

Question icon

Question 5

5.1-Differentiate-between-a-syntax-error-and-a-runtime-error-NSC Information Technology-Question 5-2020-Paper 2.png

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

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

Answer

  1. 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

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

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

Answer

  1. 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

Answer

Inc(i);

Step 7

5.6.1 What do the plus (+) and minus (-) symbols represent respectively?

96%

114 rated

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

Answer

  1. 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

Answer

toString()

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;