1.2.4 Types of Prog Languages Flashcards

1
Q

Procedural

A

-Sequence, selection, iteration
-Code developed in a modular way
-Blocks of code identify set tasks that need to be completed, utilising procedures and functions

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

Sequence, selection, iteration, recursion

A

*Sequence: Code executed line-by-line, from top to bottom
*Selection: A certain block of code is run if a specific condition is met
*Iteration: A block of code is executed a certain number of times or while a condition is met
*Recursion: Functions are expressed in terms of themselves and call themselves until a stopping condition is met (base case)

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

What is a pre-defined function?

A

Functions pre-written within a programming language

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

What is a local variable?

A

A variable that can only be accessed within the specific procedure or function it was declared in

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

What is a global variable?

A

Variable that can be accessed throughout the entire program and used by all modules

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

What is parameter passing

A

Allows variable values to be passed into procedures and functions for use in blocks of code

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

What is modularity?

A

The concept of separating the functionality of a program into individual, interchangeable blocks, each designed to carry out a single task. These all combine to make a complete program and make the program and make the program more readable

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

What is a library?

A

A collection of pre-built functions and procedures that can be linked and used by a programmer in their own code

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

Assembly language

A

-Next level up from machine code
-Converted into machine code using an assembler when code is executed
-Each instruction equivalent to one line of machine code

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

What system is assembly language useful in?

A

-Commands in assembly language are processor-specific as it directly interacts with the CPU’s special purpose registers; direct interaction of hardware THEREFORE
**Useful in embedded systems

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

Modes of addressing

A

*Machine code instructions made up of opcode and operand
*Opcode- specifies the instruction to be performed
*Operand- Holds a value which is related to the data on which the instruction is to be performed
**Addressing modes allow for a greater number of locations for data to be stored as the size of the operand would otherwise constrain the number of addresses that could be accessed

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

Immediate addressing

A

Operand is the actual value upon which the instruction is to be performed, represented in binary

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

Direct addressing

A

Operand gives the address which holds the value upon which the instruction is to be performed, used in LMC

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

Indirect addressing

A

Operand gives the address of a register which holds another address where the data is located

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

Indexed addressing

A

-An index register is used which stores a certain value.
-The address of the operand is determined by adding the operand to the index register
–Necessary to add an offset in order to access data stored contiguously in memory e.g. arrays

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

OOP- what is a class?

A

A template for an object.
Defines the state and behaviour of the object
State (properties) is given by attributes and behaviour is defined by methods associated with a class (actions it can perform)

17
Q

OOP- objects

A

A particular instance of a class
-A class can create multiple objects with the same set of attributes and methods
-Classes create objects through the process instantiation

18
Q

OOP- getters and setters

A

*Setter- a method that sets the value of a particular attribute (“set_reserved” would set the attribute reserved to True if someone were to reserve that book)
Getter- a method which retrieves the value of a given attribute
**
Both used to ensure attributes cannot be directly accessed and edited by the user (encapsulation)

19
Q

OOP- encapsulation

A

Attributes are declared as private so can only be altered by public methods

20
Q

OOP- constructors

A

“new”
Allows a new object to be created

21
Q

OOP- inheritance

A

A subclass is based on the superclass. The subclass inherits the attributes and methods of the superclass and can have its own additional properties/attributes
*Allows effective reuse of components and properties while being able to make changes
“class Biography inherits Book”

22
Q

OOP- polymorphism

A

Objects can behave differently depending on their class.
The same method can produce different outputs depending on the object involved
*Overriding: redefining a method within a subclass and altering the code so that it functions differently and produces a different output
*Overloading: passing in different parameters into a method

23
Q

Advantages of OOP

A

*Allows for a high level of reusability, makes it useful for projects where there are multiple components with similar properties (inheritance and polymorphism)
*Classes can be used across multiple projects
*Encapsulation makes code more reliable by protecting attributes from being directly accessed. Code for different classes can also be produced independently of others
*Requires advanced planning to determine how the problem will be broken down into classes etc; a thorough design can produce higher-quality software with fewer vulnerabilities
*Modular structure makes it easy to maintain and update
*High level of abstraction

24
Q

Disadvantages of OOP

A

-Requires an alternative style of thinking; can be difficult for programmers accustomed to other paradigms to pick up
-Not suited to all types of problems; where few components are reused, OOP may result in a longer, more inefficient program
-Generally unsuitable for smaller projects