2.2.1 Programming techniques Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the three programming constructs? (3)

A

Sequence (1) branching (1) iteration (1)

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

What is programming in sequence? (1)

A

Instructions run one after another (1)

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

What is iteration? (1)

A

Repeating instructions or code until an end result is achieved (1)

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

What is branching (1)

A

Choices that cause an algorithm to begin executing a different sequence of instructions (1)

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

What are the key features of recursive algorithms? (4)

A

Recursive functions call themselves (1) Recursion requires memory in the stack (1) Each recursive call adds new variables to the stack (1) Recursion often expresses a problem in fewer lines of code (1)

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

Compare recursion to iteration (4)

A

Recursion uses more memory than iteration (1) Recursion declares new variables each call while iteration uses the same variables (1) Recursion can run out of memory while iteration will not (1) Recursive functions call themselves while iterative ones don’t

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

Compare global to local variables (4)

A

Global variables are retained in memory permanantly (1) while local variables are cleared from memory when module exits (1) Global variables can be accessed from anywhere in memory (1) while local variables can only be accessed within their module (1)

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

What is the difference between byref and byval? (2)

A

byref refers to the location of the variable. Changes made change the original variable (1) byval takes a copy of the variable. Changes are made to the copy (1)

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

What is a module / subprogram? (1)

A

A repeatable section of code (1)

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

What is the difference between a procedure and a function? (2)

A

A function returns a value (1) a procedure does not (1)

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

What are the advantages of coding using sub programs? (4)

A

Small sub programs are easier to code / modify (1) Each sub program can be called multiple times (1) Avoids repeated code (1) Can reuse in other programmers (1) Tasks can be given to other programmers to complete as sub programs (1).

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

What are the advantages of coding with an IDE? (4)

A

Likely to include editor (1) compiler (1) and run time environment (1) May have autocorrect / autocomplete (1) May have debug features like breakpoints and stepping (1)

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

What are the key features of objects? (4)

A

Objects have a constructor (1) attributes (variables assigned to instance) (1) methods (subroutines assigned to instance) (1) Can be encapsulated (1)

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

What is the difference between public and private attributes? (4)

A

Private attributes can’t be accessed from outside of the instance (1) while public attributes can (1). Private attributes are usually accessed through a get method (1) while public attributes can be accessed directly.

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

What are get and set methods in classes? (2)

A

Get methods retrieve a private attribute (1) Set methods assign or change a private attribute (1)

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

What are the key features of OOP? (4)

A

OOP solves problems by means of objects that interact with each other (1) OOP uses classes as templates to construct objects (1) An object has attributes and methods associated with it (1) Objects can inherit from parent objects (1)

17
Q

What is encapsulation? (2)

A

Encapsulation is the process of keeping an object’s attributes private (1) so they can only be accessed and changed via public methods (1)

18
Q

What is polymorphism? (1)

A

Subclasses overwriting the methods of parent (or super) classes (1)

19
Q

What is inheritance? (2)

A

A class retaining the methods and attributes of its parent class (1) as well has having its own (1)