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. Arrays in most programming languages, including Delphi, are designed to store elements of a single data type, ensuring consistency in how they are accessed and manipulated.
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, arrays are typically indexed starting from 1, but the specification allows for zero-based arrays depending on how they are declared.
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 expression arrNumbers[2] + arrNumbers[3] evaluates to 2 + 3, which results in 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
If the value of 5 is entered into variable A and the value of 6 into variable B, the display will show:
6
5
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
To swap the contents of variables A and B, the algorithm should be:
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 being used in showMessage(sMeal);. This results in a runtime error instead of a compile-time error.
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 part can be completed as follows:
if iFirst > iSecond then
sMeal := 'chicken'
else if iThird < iFirst then
sMeal := 'fish'
else
sMeal := 'burgers';
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 group will have burgers if the combination of throws corresponds to:
A: 1, 2, 3
B: 2, 3, 4
C: 4, 1, 2
D: 6, 5, 4
In particular, scenario A could yield these results.
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
UML diagrams provide a clear visual representation of the structure and behavior of an object, which aids in understanding and communication among developers.
They serve as a template for constructing the object, breaking a complex object into simpler parts and indicating relationships and attributes.
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 retrieve or 'access' the value of an object's attributes without modifying them, thereby adhering to the principle of encapsulation in OOP.
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 modification of the fNumCopies attribute.