Easy1 markMultiple Choice
AQA GCSE · Question 09.2 · Programming
Which assignment statement changes the year the film Hulk was made to 2003?
Which assignment statement changes the year the film Hulk was made to 2003?
Answer options:
A.
hulk.year ← 2003
B.
filmCollection[0].year ← 2003
C.
Film(year) ← 2003
D.
hulk(year) ← 2003
How to approach this question
1. The question asks to change the year for the film *Hulk*.
2. In the code, the record for *Hulk* is created and assigned to a variable named `hulk`.
3. A record is a collection of fields. To access a specific field within a record variable, you use dot notation: `variableName.fieldName`.
4. Therefore, to access the `year` field of the `hulk` record, the syntax is `hulk.year`.
5. An assignment statement uses the `←` operator.
6. Combining these gives the statement `hulk.year ← 2003`.
Full Answer
A.hulk.year ← 2003✓ Correct
The correct answer is A (`hulk.year ← 2003`). The variable `hulk` was created to hold the record for the film Hulk. To access a field within that record, you use dot notation (`record.field`). Therefore, `hulk.year` accesses the year field of the hulk record.
In programming, a record (or `struct` or object) is a data structure that groups related variables under one name. To access an individual variable (called a field or member) within the record, you typically use dot notation.
The code creates a record for the film Hulk and stores it in a variable called `hulk`:
`hulk ← Film('Hulk', '12A', 2005, False)`
To modify the `year` field of this specific record, you reference the variable `hulk`, followed by a dot, followed by the field name `year`. The correct assignment statement is therefore `hulk.year ← 2003`.
Option B is incorrect because `filmCollection` is defined as `[antMan, hulk, ironMan]`. So, `filmCollection[0]` refers to `antMan`, not `hulk`.
Common mistakes
✗ Choosing option B, which confuses the order of elements in the `filmCollection` array.\n✗ Choosing C or D, which show incorrect syntax for accessing record fields.
Practice the full AQA GCSE Computer Science Paper 1 Python
31 questions · hints · full answers · grading
More questions from this exam
Q01.1Figure 1 shows an algorithm, represented using pseudo-code, which assigns a different value to fo...EasyQ01.2The variable `x` is assigned a value using the statement:
`x ← LEN(state)`
Using Figure 1, what ...EasyQ01.3What is the result of concatenating the contents of the variables `city` and `landmark` in Figure 1?EasyQ01.5The subroutine `POSITION` finds the first position of a character in a string.
For example, `POSI...EasyQ02.1Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-co...Easy
Expert