Types of programming languages Flashcards

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
Q

What are attributes?

A

Data recorded as a variable defining the properties associated with an object

26
Q

What are methods?

A

Program subroutines that represent an action an object can perform

27
Q

Define polymorphism

A

Where an object behaves differently depending on their class

28
Q

What is a setter?

A

A method that sets the value of a given attribute

29
Q

What is a getter?

A

A method which retrieves the value of a given attribute

30
Q

When is object oriented programming used?

A

For problems with lots of reusable components which have similar characteristics

31
Q

What is the main advantage of OOP?

A

It makes programs that are reusable and easy to update and maintain

32
Q

Why are getters and setters used?

A

To ensure that attributes cannot be directly accessed and edited by users

33
Q

State the advantage of encapsulation

A

Helps keep data related to an object safe

34
Q

Why are attributes declared as private?

A

So they can only be altered by public methods

35
Q

State the advantage of inheritance

A

It allows programmers to effectively reuse certain components and properties whilst making changes

36
Q

State the two types of polymorphism

A

Overriding
Overloading

37
Q

State 3 advantages of OOP

A
  • 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
Q

State two disadvantages of OOP

A
  • 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
Q

Define functional programming

A

The concept of reusing a set of functions

Code is made up of lines of function calls combined together

40
Q

State an example of a functional language

A

Haskell
C#
Java

41
Q

Define logic programming

A

Code which defines a set of facts and rules based on the problem
Queries are used to find answers to the problem

42
Q

State an example of a logic programming language

A

Prolog

43
Q

Where is assembly language useful and why?

A

In embedded systems because it allows direct interaction with the hardware

44
Q

Why are assembly language commands processor specific?

A

Because they directly interact with the CPU’s special purpose registers

45
Q

What is the purpose of the opcode?

A

To specify the instruction to be performed

46
Q

What is the purpose of the operand?

A

To hold a value which is related to the data in which the instruction is to be performed

47
Q

What is the purpose of addressing modes?

A

To allow for much greater number of locations for data to be stored

48
Q

What do addressing modes do?

A

They specify how the operand should be interpreted

49
Q

Define immediate addressing

A

The operand is the actual value upon which the instruction is to be performed

50
Q

Define direct addressing

A

The operand gives the address of the value upon which the instruction is to be performed

51
Q

Define indirect addressing

A

The operand gives the address of a register which holds another address, where the data is located

52
Q

Define index addressing

A

The address of the operand is determined by adding the operand to a value in an index register

53
Q

Why is index addressing used?

A

To add an offset in order to access data stored contiguously in memory (arrays)