The group of IT friends are writing customised programs for their business - NSC Information Technology - Question 5 - 2016 - Paper 2
Question 5
The group of IT friends are writing customised programs for their business.
5.1 Indicate how many times each of the following loops will be executed:
5.1.1 k < 1
r... show full transcript
Worked Solution & Example Answer:The group of IT friends are writing customised programs for their business - NSC Information Technology - Question 5 - 2016 - Paper 2
Step 1
5.1.1 k < 1
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 loop will be executed once. The loop condition 'k < 1' must initially be true for the loop to execute. When 'k' equals 1, the loop will stop.
Step 2
5.1.2 k < 0
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 loop will result in an infinite loop because the condition 'k >= 0' will always be true if 'k' starts from any non-negative value and never changes. Thus, the instructions within the loop will execute continuously.
Step 3
5.2.1 What does it mean to instantiate an object?
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
To instantiate an object means to create a specific instance of a class in memory, allocating the necessary resources to hold the attributes associated with that object.
Step 4
5.2.2 (a) 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 is used to retrieve private data from an object without allowing external modification. It provides a way to obtain attribute values.
Step 5
5.2.2 (b) A mutator method
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
A mutator method is used to modify the values of an object's attributes. It sets or changes the state of an object.
Step 6
5.2.3 Write an algorithm for the CalculateCost(LogoutTime)
97%
121 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!