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
TRUE. An array in most programming languages, including Delphi, is indeed designed to store elements of a single type.
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
FALSE. In Delphi, the default behavior is that the first index is 1, but it can be defined to start at 0 based on the array declaration.
Step 3
5.1.3 The value 23 will be displayed in the rich edit component.
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
FALSE. The code adds the values at index 2 (2) and index 3 (3) of the array, which results in 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 result displayed will be:
6
5
This is because the values are swapped successfully.
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
Input A
Input B
Temp <- A
A <- B
B <- Temp
Display A
Display 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 occurs because the variable sMeal is declared as a string but is not assigned a value before it is used in the showMessage(sMeal); line.
Step 7
5.3.2 Complete the missing part for the program provided.
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
if iFirst > iSecond then
sMeal := 'chicken'
else if iThird < iFirst then
sMeal := 'fish'
else
sMeal := 'burgers';
This code structure ensures meals are assigned based on the thrown values.
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 B will result in having burgers as a meal because it does not satisfy the conditions for eating chicken or fish.
Step 9
5.4.1 Give TWO reasons why an 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
It specifies the structure and behavior of an object, providing a visual representation.
It offers a template that aids in designing and constructing an object.
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
The purpose of an accessor method is to return the current value of an attribute of an object, allowing read-only access to private variables.
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 would be used to change the value of fNumCopies.