Skip to content
Marlbridge

Flashcards · 7517 · Topic 1

Fundamentals of programming flashcards

15 cards on Topic 1, subtopics 4.1.1 to 4.1.2. Pick a subtopic or study them all.

Study mode needs JavaScript. Every card is listed below, so you can still cover the answers and test yourself.

All 15 cards

For a quick read-through or printing. Cover the right-hand side to test yourself.

4.1.1 Programming

What is the difference between a variable and a named constant?
A variable’s value can change while the program runs. A named constant’s value is fixed; naming it makes code easier to read and to update in one place.
What are the three basic programming constructs?
Sequence (steps in order), selection (choosing a path, e.g. IF or CASE) and iteration (repetition: definite, e.g. FOR, or indefinite, e.g. WHILE).
What is the difference between definite and indefinite iteration?
Definite: the number of repetitions is known before the loop starts (count-controlled). Indefinite: the loop repeats until a condition is met; the condition may be tested at the start or the end.
What is the difference between a local and a global variable?
A local variable exists only inside the subroutine that declares it. A global variable can be accessed anywhere in the program. Local variables avoid unintended side effects.
What is the difference between passing a parameter by value and by reference?
By value: a copy is passed, so the original is unchanged. By reference: the memory address is passed, so changes affect the original.
What is a stack frame?
The data pushed onto the call stack for each subroutine call: the return address, the parameters and the local variables.
What is exception handling?
Code that detects an error at run time (such as a missing file or invalid input), deals with it and lets the program continue or end cleanly instead of crashing.
What is a recursive subroutine and what must it have?
A subroutine that calls itself. It needs a base case (stopping condition) that is reached after a finite number of calls; otherwise the stack overflows.

4.1.2 Programming paradigms

What is the procedural-oriented paradigm?
A program is a sequence of instructions grouped into subroutines (procedures and functions), with the problem solved by stepwise refinement into a hierarchy of modules.
What are a class, an object and instantiation?
Class: a template defining attributes and methods. Object: an instance of a class. Instantiation: creating an object from a class, using its constructor.
What is encapsulation?
Combining an object’s attributes and methods, with the attributes kept private and accessed only through public methods.
What is inheritance?
A subclass takes on the attributes and methods of its superclass and can add or override its own: an “is a” relationship.
What is the difference between aggregation and composition?
Both are “has a” relationships. Composition: the contained object is destroyed when its container is destroyed. Aggregation: the contained object can exist on its own.
What is polymorphism and what is overriding?
Polymorphism: the same method name behaves differently depending on the object’s class. Overriding: a subclass replaces a method it has inherited with its own version.
What are the three OOP design principles in the AQA specification?
Encapsulate what varies; favour composition over inheritance; program to interfaces, not implementation.