Past-paper question · 2021 May-June · Paper 42 · Q3(b)

Question 3(b) 2021 · May-June · Paper 42 · 4 marks

Original past-paper question for 3(B)
Original past-paper question for 3(B)
Original past-paper question for 3(B)
Reveal official mark-scheme answer Official mark-scheme answer for 3(B)

Official answer for Question 3

Part (b)

Question 1

mark per bullet point to max 4

Question 4

  • Function header and close, taking parameter of type QuestionClass if data type given
  • Checking if array is full …
  • …returning FALSE if it is full
  • (otherwise) store object in next position in array // append to array…
  • …increment NumberOfQuestions and return TRUE
✓
Example code
✓
VB.NET
✓
Public Function AddQuestion(QuestionObject)
✓
If NumberOfQuestions < 20 Then
✓
Questions(NumberOfQuestions) = QuestionObject
✓
NumberOfQuestions = NumberOfQuestions + 1
✓
return True
✓
Else
✓
return False
✓
End If
✓
End Function
✓
Python
✓
def AddQuestion(self, QuestionObject):
✓
if self.__NumberOfQuestions < 20:
✓
self.__Questions[self.__NumberOfQuestions] = QuestionObject
✓
self.__NumberOfQuestions = self.__NumberOfQuestions + 1
✓
return True
✓
else:
✓
return False
✓
9608/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2021
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s21_ms_42.pdf →

Show text version of question

Question 3

Part (b)

Question 3

Ejaz is creating a program that will allow the user to create quizzes. He is using object-oriented

programming (OOP).

There are two classes: QuestionClass and QuizClass.

The class attributes and methods are in the following tables. All attributes are declared as private.

QuestionClass

Question : STRING // stores the question

Answer : STRING // stores the correct answer

Difficulty : INTEGER // stores the difficulty as an integer // from 0(easy) to 10(hard) Constructor(QuestionP, AnswerP, // creates an instance of QuestionClass DifficultyP) // sets the attributes to the parameter // values

GetQuestion() // returns the question

GetDifficulty() // returns the difficulty level

GetAnswer() // returns the answer

QuizClass

// stores maximum 20 questions of Questions : ARRAY[0:19] OF QuestionClass // type QuestionClass

// stores the number of questions NumberOfQuestions : INTEGER // in this quiz // creates an instance of Constructor() // QuizClass // initialises NumberOfQuestions // to 0

// adds the parameter question to AddQuestion() // the array // increments NumberOfQuestions

// returns the next question to be GetQuestion() // asked

// takes an answer as a parameter CheckAnswer() // and returns TRUE if correct

Question 9

Part (b)

The QuizClass method AddQuestion() takes a question object as a parameter and stores

it in the next available location in the array Questions. It returns TRUE if it is successfully stored, and FALSE otherwise.

Write program code for the method AddQuestion().

Programming language .................................................................

Program code

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

[4]
Topic relevance

Why this question appears here

98% assigned-topic match · Further programming › Programming paradigms

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s21_qp_42.pdf

Keep practising this topic