Answer
Flashcards · 9618 · A Level Topic 20
Further Programming (A Level) flashcards
9 cards on A Level Topic 20, subtopics 20.1 to 20.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.
Choose your cards
Session complete
Worth another look:
All 9 cards
For a quick read-through or printing. Cover the right-hand side to test yourself.
20.1 Programming Paradigms
- What is the difference between low-level, imperative, object-oriented and declarative paradigms?
- Low-level: works directly with the processor’s instructions and registers. Imperative (procedural): a sequence of statements that change state. Object-oriented: objects combining data and methods. Declarative: states facts and rules; the system works out how to answer a goal.
- What are a class, an object and a constructor?
- Class: a template defining attributes and methods. Object: an instance of a class. Constructor: the method that creates and initialises a new object.
- What are encapsulation and inheritance?
- Encapsulation: attributes are kept private and accessed only through the object’s methods (getters and setters). Inheritance: a subclass takes on the attributes and methods of its parent class and can add its own.
- What is polymorphism?
- A method with the same name behaves differently depending on the class of the object; a subclass can override an inherited method.
- How does a declarative (logic) program answer a query?
- It holds facts, e.g. parent(ali, sara), and rules, e.g. grandparent(X, Z) IF parent(X, Y) AND parent(Y, Z). A goal (query) is answered by matching it against the facts and rules.
20.2 File Processing and Exception Handling
- What is an exception?
- An unexpected event during program execution that disrupts the normal flow, such as a missing file, division by zero or invalid input.
- What is exception handling and why is it used?
- Code that catches an exception and deals with it (e.g. with try … except/catch) so the program does not crash and can report the problem or recover.
- How do you read a record from a random file in 9618 pseudocode?
- OPENFILE "Stock.dat" FOR RANDOM SEEK "Stock.dat", Position GETRECORD "Stock.dat", ThisItem CLOSEFILE "Stock.dat"
- How do you add a record to a sequential file while keeping it in key order?
- Read each record from the old file and write it to a new file until the correct position is reached; write the new record; copy the rest; then replace the old file with the new one.