1.2.4 types of programming languages Flashcards

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

what are programming paradigms

A

Different approaches to using a programming language to solve problems.

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

which two broad categories are programming paradigms split into

A

-imperative
-declarative

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

Imperative programming paradigms

A

uses code that clearly specifies the actions to be
performed

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

Declarative programming paradigms

A

focuses on stating the desired result rather than the exact series of instructions that need to be performed to get to the result. . It is the role of the programming language to determine how best to obtain the result and the details about how it is obtained are abstracted from the user.

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

Advantages of procedural programming

A

-can be 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
6
Q

procedural programming

A

This is a type of imperative programming which uses a sequence of
instructions which may be contained within procedures. These instructions are carried out in a step-by-step manner.

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

state a use of declarative programming

A

-Artificial intelligence
-expert systems/knowledge based systems

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

identify the 4 main structures used in structural programming

A

-sequence
-selection
-iteration
-recursion

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

Sequence

A

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
10
Q

Selection

A

A certain block of code is run if a specific condition is met, using IF
statements.

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

Iteration

A

A block of code is executed a certain number of times or while a condition is met. Iteration uses FOR, WHILE or REPEAT UNTIL loops.

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

Recursion

A

Functions are expressed in terms of themselves. Functions are executed, calling themselves, until a certain condition known as a base case (which does not call the function) is met.

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

what is procedural programming suited for

A

suited to problems that can easily be expressed as a series of instructions

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

how does assembly language differ from machine code

A

Assembly language uses mnemonics rather than binary. One line in assembly language is equal to one line in machine code

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

mnemonics

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

state the function of opcode and operand

A

the opcode specifies the instruction to be preformed and addressing mode. The operand holds a value which is related to the data on which the instruction is to be preformed

17
Q

state 4 addressing modes

A

-immediate addressing
-direct addressing
-indirect addressing
-indexed addressing

18
Q

Immediate Addressing

A

The operand is the actual value upon which the instruction is to be performed, represented in binary. So the memory does not need to be searched to find the required value

19
Q

Direct Addressing

A

The operand gives the address which holds the value upon which the instruction is to be performed. Direct addressing is used in LMC.

20
Q

Indirect Addressing

A

The operand gives the address of a memory location which holds another address, where the data is located.

21
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. This is necessary to add an offset in order to access data stored contiguously in memory such as in arrays

22
Q

Advantages of oop

A

-oop allows for high level of usability which makes it useful for projects with many components

-classes can be used across multiple projects

-There is a high level of abstraction and it is not necessary for programmers to know details about how code is implemented.

-The modular structure used in OOP makes it easy to maintain and update.

-Encapsulation is a key reason for choosing OOP as it makes the code more reliable by protecting attributes from being directly accessed.

23
Q

Polymorphism

A

Ability for methods of the same name to be used in inherited classes with different behaviours exhibited

24
Q

Inheritance

A

Inheritance is when a class takes on the methods and attributes of a parent class. The inheriting class may override some of these methods/attributes and may have additional extra methods and attributes of its own

25
Q

Class

A

A template defining methods and attributes used to make objects

26
Q

Encapsulation

A

The hiding of the implementation of a class and controlling access to its methods and attributes

27
Q

Object

A

An object is an instance of a class

28
Q

disadvantages of OOP

A
  • This is a different style of programming and so requires an alternative style of thinking. This can be difficult for programmers accustomed to other paradigms to pick up.
  • OOP is not suited to all types of problems. Where few components are reused, OOP may in fact result in a longer, more inefficient program.
  • Generally unsuitable for smaller problems.
29
Q

overriding

A

Overriding is redefining a method within a subclass and altering the code so that it functions differently and produces a different output.

30
Q

Overloading

A

Overloading is passing in different parameters into a method. Both of these forms of polymorphism would produce different results which would depend on the scenario

31
Q

Assembly language

A

Assembly language is the next level up from machine code
and is part of a family of low level languages. This is converted to machine code using an assembler when it is executed. Assembly language uses mnemonics rather than binary, which makes it easier to use than direct machine code.

32
Q

getter and setters

A

● A setter is a method that sets the value of a particular attribute
● A getter is another special method used in OOP which retrieves the value of a given
attribute
● Getters and setters ensure attributes cannot be directly accessed and edited but
can only be altered by public methods. This is called encapsulation.
● Every class must also have a constructor method which allows a new object to be
created