5.1 Indicate whether the following statements are TRUE or FALSE - NSC Information Technology - Question 5 - 2021 - Paper 2
Question 5
5.1 Indicate whether the following statements are TRUE or FALSE. Write only 'true' or 'false' next to the question numbers (5.1.1 to 5.1.3 in the ANSWER BOOK).
5.1.... show full transcript
Worked Solution & Example Answer:5.1 Indicate whether the following statements are TRUE or FALSE - NSC Information Technology - Question 5 - 2021 - Paper 2
Step 1
5.1.1 An array can only store elements of the same data type.
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
This statement is TRUE. An array, by definition, is a collection of elements that are all of the same type. For instance, in Delphi, an array defined as array of Integer can only hold integer values.
Step 2
5.1.2 The index value for the first element in a Delphi array is always one.
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
This statement is FALSE. In Delphi, the default index for the first element of an array is zero unless specified otherwise with a different index range.
Step 3
5.1.3 The value 23 will be displayed in the rich edit component when the following code is executed.
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
This statement is FALSE. The code calculates iValue as arrNumbers[2] + arrNumbers[3], which is 2 + 3 = 5, not 23.
Step 4
5.2.1 What will be displayed if the value of 5 is entered into variable A and the value of 6 is entered into variable B?
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 output will display 6 for variable B. Since no swapping of values happens in the display statements, the last value entered will be shown.
Step 5
5.2.2 Rewrite the algorithm so that the content of the variables will be swapped correctly.
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
The corrected algorithm should be:
Input A
Input B
Temp <- A
A <- B
B <- Temp
Display A
Display B
This correctly swaps the values of A and B.
Step 6
5.3.1 Explain why a syntax error will be displayed when the provided part of the program is executed.
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
A syntax error will occur because the variable sMeal is used without being properly initialized. The variable should be assigned a value based on the rules before it's displayed.
Step 7
5.3.2 Complete the missing part for the program provided, to assign the correct type of meal to the sMeal variable according to the rules in the scenario above.
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 missing code portion can be:
if iFirst > iSecond then
sMeal := 'chicken'
else if iThird < iFirst then
sMeal := 'fish'
else
sMeal := 'burgers';
This ensures that sMeal is assigned appropriately based on the values of the dice throws.
Step 8
5.3.3 Which sequence of throws (A, B, C or D) will result in the group of friends having burgers as a meal?
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 sequence that will result in burgers is B. This sequence must satisfy the condition that neither of the previous conditions for chicken or fish is met.
Step 9
5.4.1 Give TWO reasons why a UML diagram is an important OOP modelling tool.
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
UML diagrams help to visually represent the structure and behavior of an object, making it easier for developers to understand the system design.
They serve as templates for constructing objects and provide a breakdown of complex components into manageable units.
Step 10
5.4.2 What is the purpose of an accessor method?
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
An accessor method allows for the retrieval of the value of an attribute of an object without modifying it. It provides a way to access private data.
Step 11
5.4.3 Give an example of a mutator method in the given class diagram.
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
An example of a mutator method in the given class diagram is setNumCopies(), which allows the modification of the fNumCopies attribute.