Computer Science For First Examination In 2021 9618 · 20

20.1 Programming paradigms

145 questions in this subtopic. Open a question to solve it and check the official answer.

Reset
2025 October-November · Paper 41 · Q2(a)(i)

Programming paradigms · 4 marks · official answer ready

(i) Write program code to declare the class Train and its constructor. Do not declare the other methods. All attributes should be private. Use your programming language appropriat…

2025 October-November · Paper 41 · Q2(a)(ii)

Programming paradigms · 3 marks · official answer ready

(ii) The methods GetTrainIDNumber() and GetRoute() return the appropriate attribute. Write program code for GetTrainIDNumber() and GetRoute() Save your program. Copy and paste the…

2025 October-November · Paper 41 · Q2(b)

Programming paradigms · 2 marks · official answer ready

(b) The program is tested with four trains: train ID number route 12ADV 134 33ART 20 9FKF 3 21VBC 24 Write program code to declare an instance of Train for each of the four trains…

2025 October-November · Paper 41 · Q2(c)(i)

Programming paradigms · 3 marks · official answer ready

(i) Write program code to declare the class Station and its constructor. Do not declare the other methods. All attributes should be private. Use your programming language appropri…

2025 October-November · Paper 41 · Q2(c)(ii)

Programming paradigms · 4 marks · official answer ready

(ii) The method AddTrain() takes a Train parameter. The method compares the attributes NumberTrains and NumberPlatforms to identify if there is a platform available (a platform cu…

2025 October-November · Paper 41 · Q2(c)(iii)

Programming paradigms · 6 marks · official answer ready

(iii) The method GetTrains() returns the string "There are no trains" if there are no trains at the station platforms. If there are trains at the station platforms, the method ret…

2025 October-November · Paper 41 · Q2(d)(i)

Programming paradigms · 2 marks · official answer ready

(i) Write program code to amend the main program to declare an instance of Station for each of the two stations. Save your program. Copy and paste the program code into part 2(d)(…

2025 October-November · Paper 41 · Q2(d)(ii)

Programming paradigms · 4 marks · official answer ready

(ii) The four trains attempt to stop at the following stations in the order given: • Train 12ADV, station STH • Train 33ART, station STH • Train 9FKF, station STH • Train 21VBC, s…

2025 October-November · Paper 41 · Q2(d)(iii)

Programming paradigms · 2 marks · official answer ready

(iii) Test your program. Take a screenshot of the output(s). Save your program. Copy and paste the screenshot(s) into part 2(d)(iii) in the evidence document. [2] 9

2025 October-November · Paper 41 · Q4(a)

Programming paradigms · 2 marks

(a) The class Record stores data about the records: Record Key : Integer stores the integer key field for the data Data : String stores the string data Constructor() initialises K…

2025 October-November · Paper 41 · Q4(b)

Programming paradigms · 2 marks

(b) The procedure InitialiseHashTable() initialises each element in the array to an empty or null record. Write program code to declare the global 2D array HashTable and the proce…

2025 October-November · Paper 41 · Q4(c)

Programming paradigms · 2 marks

(c) The function Hash(): • takes an integer key field as a parameter • calculates and returns the hash value of the key field. The hash value is the result from the formula: key M…

2025 October-November · Paper 41 · Q4(d)

Programming paradigms · 4 marks

(d) The procedure InsertData(): • takes an object of type Record as a parameter • calculates the hash value for the parameter using the appropriate function • stores the parameter…

2025 October-November · Paper 41 · Q4(e)

Programming paradigms · 5 marks

(e) The file "HashTableData.txt" stores 200 key values and string data items in the format: key,string For example, the first row in the text file is: 528,permission The key is 52…

2025 October-November · Paper 41 · Q4(f)

Programming paradigms · 5 marks

(f) The function GetRecord(): • takes an integer key field as a parameter • calculates the hash value for the key field using the appropriate function • searches the hash table fo…

2025 October-November · Paper 41 · Q4(g)(i)

Programming paradigms · 3 marks

(i) Write program code for the main program. Save your program. Copy and paste the program code into part 3(g)(i) in the evidence document. [3]

2025 October-November · Paper 41 · Q4(g)(ii)

Programming paradigms · 2 marks

(ii) Test your program with the following five inputs in the order given: 528 1128 1828 1062 39 Take a screenshot of the output(s). Save your program. Copy and paste the screensho…

2025 October-November · Paper 42 · Q1(a)(i)

Programming paradigms · 4 marks · official answer ready

(i) Write program code to declare the class Bird and its constructor. Do not declare the other methods. All attributes should be private. Use your programming language appropriate…

2025 October-November · Paper 42 · Q1(a)(ii)

Programming paradigms · 2 marks · official answer ready

(ii) The method GetSpecies() returns the species of the bird. Write program code for GetSpecies() Save your program. Copy and paste the program code into part 1(a)(ii) in the evid…

2025 October-November · Paper 42 · Q1(a)(iii)

Programming paradigms · 3 marks · official answer ready

(iii) The method GetPosition() returns a string of the bird’s data in the format: "X = " & & " Y = " & An example string for a bird is: X = 500.0 Y = 250.0 Write program code for …