1.2.4 - Types of Programming Language Flashcards

1
Q

What are programming paradigms?

A

Different approaches 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

What are imperative programming paradigms?

A

These are paradigms which clearly specify the action to be performed.

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

What is 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
4
Q

Why is procedural programming good?

A
  • Applied to a wide range of problems

- Easy to write and interpret

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

What is OOP?

A

OOP is built on entities called objects formed from classes which have certain attributes and methods. OOP focuses on making programs that are reusable and easy to update and maintain.

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

Why is OOP good? (structure)

A

OOP is applicable to certain types of problem with lots of reusable components which have similar
characteristics. This is because of inheritance and polymorphism.
It also has a modular structure, meaning classes can be easily maintained and updated.

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

What is declarative programming?

A

Declarative programming 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
8
Q

When is declarative programming used?

A

It is common in expert systems and artificial intelligence.

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

What is functional programming?

A

Functional programming uses the concept of reusing a set of functions, which form the core of the program. Programs are made up of lines of code consisting of function calls, often combined within each other. Functional programming is closely linked to mathematics.

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

What is logic programming?

A

Logic languages are also part of the declarative programming paradigm and use code
which defines a set of facts and rules based on the problem.
Queries are used to find
answers to problems.

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

What is structured programming?

A

Structured programming is a popular subsection of procedural programming in which the
control flow is given by four main programming structures: sequence, selection, iteration and recursion.

Procedural programming is suited to problems that can easily be expressed as a series of instructions using the above constructs.

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

What does sequence mean?

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

What does selection mean?

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

What does iteration mean?

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

What does recursion mean?

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

What is an addressing mode?

A

This is what specifies how the operand should be interpreted. The addressing mode is part of the opcode.

17
Q

What is immediate addressing?

A

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

18
Q

What is 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.

19
Q

What is indirect addressing?

A

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

20
Q

What is 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.

21
Q

What is the class of an object?

A

A template for an object, defining it’s state and behaviour.

22
Q

What is the state and behaviour of an object?

A

State is given by attributes which give an object’s properties.
Behaviour is defined by the methods associated with a class, which describe the actions it can perform.

23
Q

What are setters and getters?

A

A setter is a method that sets the value of a particular
attribute.
A getter retrieves the value of a given attribute.
They make sure attributes can’t be directly accessed and edited by users (encapsulation)

24
Q

How does encapsulation work?

A

Attributes are declared as private so can only be altered by public methods.
Every class must also have a constructor method, which is called ‘new’. A constructor
allows a new object to be created.

25
Q

What is inheritance?

A
A class can inherit from another class.
The subclass (or derived class) will possess all of the methods and attributes of the superclass (or parent class) and can have its own additional properties.
26
Q

Why is inheritance good?

A

Inheritance allows programmers to effectively reuse certain components and properties while making some changes.

27
Q

How is inheritance expressed

A

class ______ inherits ____

28
Q

What is polymorphism?

A

This is a property of OOP which means some objects can behave differently during their class.
This means the same method can produce different results depending on the involved object.

29
Q

What is 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

What is overloading?

A

Overloading is passing in different parameters into a method

31
Q

Why is OOP good (principles)?

A

It requires advance planning to determine how the problem will be broken into classes and how they will link, generating a thorough design with fewer vulnerabilities.
There is a high level of abstraction and once classes are made other programmers don’t need to know the details.

32
Q

Why is OOP bad?

A
  • Difficult to pick up, different style of thinking.
  • Not suited to all types of problems - could result in a longer, more inefficient problem where not many sections are repeated.
  • Unsuitable for smaller problems.