4.1 Fundamentals of Programming Flashcards

1
Q

What is the role of a data type?

A

To define which computations/operations may be carried out on the bit patterns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

2016 Additional A-Level paper 1

What is meant by a recursive subroutine? [1]

A

A subroutine that calls itself;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

2016 Additional A-Level paper 1

State two items that will be stored in a stack frame for a subroutine call [2]

A

1) Return address
2) Parameters

Additional answers: Local variables, Return value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

2016 Additional A-Level paper 1

State one reason why many programmers follow the design principle:

“favour composition over inheritance”. [1]

A

**Easier to test each class using unit testing ** // with composition each
class can be tested separately but it is not possible to test a subclass
independently from the base class;

There can be unintended side-effects for derived classes if a method in
the base class is altered
;

Composition is more flexible as if a new class is developed it can easily
be used instead of the class that currently is used in the composition;

MAX 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

2016 Additional A-Level paper 2

Describe the relationships association aggregation and composition aggregation, making it clear what the difference between the two is. [2]

A

Composition and association are both “has a” relationships
An object contains another object;

With composition if the containing object is destroyed so are the objects
it contains, this is not the case with association;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Name 3 OOP design principles

A

1) Encapsulate what varies
2) Program to interfaces, not implmentation
3) Favour composition over inheritence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Name 2 advantages of “programming to interfaces, not implementation”

A

1) Makes it easier to edit code in the future
2) Makes it easier to test each class individually.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

2017 A-Level Paper 1

Explain the differences between static and dynamic data structures. [2]

A

Static data structures use a fixed amount of memory, declared at run time.
Dynamic data structures can grow and shrink as necessary.

static data structures have storage size determined before program is run; dynamic data structures can grow/shrink during execution / at run-time;

Static data structures can waste storage space/memory if the number of data items stored is small relative to the size of the structure; dynamic data structures only take up the amount of storage space required for the actual data;

Static data structures have fixed (maximum) size; whereas size of dynamic data structures can change;

Dynamic data structures (typically) require memory to store pointer(s) to the next item(s); which static data structures (typically) do not need; NE. Dynamic data structures use pointers

Static data structures (typically) store data in consecutive memory locations; which dynamic data structures (typically) do not;

MAX 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the advantages of using Object Oriented Programming? (OOP)

A

Allows for modular code
Easier to test individual classes
Allows for code reuse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a ‘constant’

A

A variable that keeps the same value whilst the code is being run. It cannot be updating during run-time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the advantages of using recursion?

A

It can lead to short, elegant code
Sometime recursion is the only way to solve a problem
Sometimes people think recursively

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the disadvantages of using recursion?

A

> Can take up memory space
Can take a long time for larger values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What error may occur if a recursive subroutine never meets it’s base case?

A

Stack Overflow error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the advantages of using local variables?

A

Local variables cannot be changed by code in other subroutines
Names of local variables can be repeated in other subroutines
Reduces overall complexity of debgugging the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the characteristics of a high level language?

A

> Problem oriented
Uses Syntax similar to human language
High levels of abstraction
Translated into machine code for the computer to process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the advantages of a high-level language?

A

Portable
easier to write programs
Come with libraries of pre-written code

17
Q

What is the most appropriate programming paradigm for distributed processing?

A

Functional programming

18
Q

What is ‘Encapsulation?’

A

Combining methods and properties and being able to restrict their access

19
Q

What is an ‘Exception handler’

A

A program run when an exception is encountered. Once the exception has been dealt with, the original program is resumed

20
Q
A