Types of programming languages Flashcards

(53 cards)

1
Q

What is a programming paradigm?

A

A different approach to using a programming language to solve a problem

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

State the two categories of programming paradigm

A

Imperative
Declarative

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

State one type of imperative paradigm

A

Procedural
Object Oriented

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

State one type of declarative paradigm

A

Logic
Functional

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

Define imperative programming

A

Code that clearly specifies the actions to be performed

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

Define declarative programming

A

Code that focuses on stating the desired result rather than a series of instructions that need to be performed to get the result

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

Define procedural programming

A

Code which uses a sequence of instructions carried out step-by-step, which may be contained within procedures

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

When should procedural programming be used?

A

For problems that can easily be expressed as a series of instructions using programming constructs

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

State two advantages of procedural programming

A
  • Can be easily applied to a wide range of problems
  • relatively easy to write and interpret
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

State two languages that use procedural programming

A

Pascal
Python
Logo

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

Name a subsection of procedural programming

A

Structured programming

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

State the programming structures of structured programming

A

Sequence
Selection
Iteration
Recursion

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

Define sequence

A

Where code is executed line-by-line from top to bottom

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

Define selection

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

Define iteration

A

Where a block of code is executed a certain number of times or while a condition is met

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

Define recursion

A

Where functions are executed until a base case condition is met

  • functions are expressed in terms of themselves
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Define object oriented programming

A

A programming language where the code is made up of units called objects, which are instances of a class

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

What are objects?

A

Instances of a class which have their own attributes and methods and can interact with each other

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

What is a class?

A

A template defining the attributes and methods that can be used to create an object

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

Define encapsulation

A

A method of maintaining data integrity by only allowing class methods to access data in an object’s attributes

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

Define instantiation

A

The process of creating an object from a class template

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

What is a constructor method?

A

A special method within the class that runs when an object of that class type is created, it allows a new object to be created

23
Q

Define inheritance

A

Where a class retains the methods and attributes of its parent class as well as having its own

24
Q

Define overriding

A

Where a method is redefined within a subclass so that it functions differently and produces a different output

25
What are attributes?
Data recorded as a variable defining the properties associated with an object
26
What are methods?
Program subroutines that represent an action an object can perform
27
Define polymorphism
Where an object behaves differently depending on their class
28
What is a setter?
A method that sets the value of a given attribute
29
What is a getter?
A method which retrieves the value of a given attribute
30
When is object oriented programming used?
For problems with lots of reusable components which have similar characteristics
31
What is the main advantage of OOP?
It makes programs that are reusable and easy to update and maintain
32
Why are getters and setters used?
To ensure that attributes cannot be directly accessed and edited by users
33
State the advantage of encapsulation
Helps keep data related to an object safe
34
Why are attributes declared as private?
So they can only be altered by public methods
35
State the advantage of inheritance
It allows programmers to effectively reuse certain components and properties whilst making changes
36
State the two types of polymorphism
Overriding Overloading
37
State 3 advantages of OOP
- Allows for high level of re usability enabled my inheritance and polymorphism - Classes can be used across multiple projects - Code is more reliable because encapsulation protects attributes from being directly accessed and accidentally altered - Code for other classes can be produced independent of the others - Can result in high-quality piece of software with fewer vulnerabilities - Modular structure makes it easy to maintain and update - High level of abstraction which saves time and effort
38
State two disadvantages of OOP
- Requires an alternative style of thinking because it is a different style of programming - no suited to all types of problems, especially where few components are reused - Unsuitable for smaller programs
39
Define functional programming
The concept of reusing a set of functions Code is made up of lines of function calls combined together
40
State an example of a functional language
Haskell C# Java
41
Define logic programming
Code which defines a set of facts and rules based on the problem Queries are used to find answers to the problem
42
State an example of a logic programming language
Prolog
43
Where is assembly language useful and why?
In embedded systems because it allows direct interaction with the hardware
44
Why are assembly language commands processor specific?
Because they directly interact with the CPU’s special purpose registers
45
What is the purpose of the opcode?
To specify the instruction to be performed
46
What is the purpose of the operand?
To hold a value which is related to the data in which the instruction is to be performed
47
What is the purpose of addressing modes?
To allow for much greater number of locations for data to be stored
48
What do addressing modes do?
They specify how the operand should be interpreted
49
Define immediate addressing
The operand is the actual value upon which the instruction is to be performed
50
Define direct addressing
The operand gives the address of the value upon which the instruction is to be performed
51
Define indirect addressing
The operand gives the address of a register which holds another address, where the data is located
52
Define index addressing
The address of the operand is determined by adding the operand to a value in an index register
53
Why is index addressing used?
To add an offset in order to access data stored contiguously in memory (arrays)