Types of Programming Language Flashcards

1
Q

Name the four programming paradigms in the specification

A

Procedural, Object-Oriented, Functional and Declarative

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

How does procedural programming work?

A

A series of instructions tell the computer how to handle the data given in order to solve the problem.

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

What is structured programming?

A

A type of procedural programming which utilities the programming concepts of SIRS, Selection, Iteration, Recursion and Sequencing.

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

What data types do procedural languages have available?

A

Integer, Real, Floating numbers. Characters Boolean and String.

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

What data structures are found in procedural languages?

A

Arrays and records, however programmers can abstract their own data types such as stacks, queues, trees or a hash table.

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

What is a class?

A

A class is a template description of the methods and variables available within the objects produced from said class

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

What is a object?

A

A object is a instance of a class.

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

What are the three defining features of OOP?

A

Inheritance, Polymorphism and Encapsulation.

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

What is inheritance?

A

Inheritance is the ability of a class to take attributes from another, when a class does this it is a sub class and the class the attributes were taken from is a super class.

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

What is polymorphism?

A

The ability of the programming language to differentiate between objects based on their class.

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

What is encapsulation?

A

The bundling of data with the methods that operate on and restrict direct access to it.

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

What are three advantages of OOP?

A

OOP methodology forces programmers to undertake extensive planning which makes for better design less prone to bugs.

Re usability, Objects defined, coded and tested can be reused in many different programs.

Maintenance, The modular structure of OOP makes it easier to maintain than other paradigms.

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

What is functional programming?

A

Functional programming is where statements are written as a series of functions where data input is taken as arguments and a output is produced.

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

What is declarative programming?

A

Where the programmer outlines the problem in statements and the programming language decides how best to solve said problem.

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

Give an example of a language that supports each programming paradigm.

A

Procedural - Python, Pascal
Object orientated - Java,Python,Delphi
Declarative - SQL
Functional - Haskell,Python,C#,Java.

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

How does an assembly language work?

A

Operation codes and addresses are represented using mnemonics, the assembler translates these into machine code for execution.

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

Name all four addressing modes.

A

Indexed addressing
Direct addressing
Immediate addressing
Indirect addressing

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

Explain indexed addressing.

A

Indexed addressing is when the operand contains the number of the index register and the constant value, the constant value is added to the index register in order to find the address of the data to be operated on.

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

What is immediate addressing?

A

When the operand holds the data to be operated on

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

What is direct addressing?

A

When the operand holds the address of the data to be operated on.

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

What is indirect addressing?

A

When the operand holds the address of the memory location where the address of the data to be operated is.

22
Q

Give an example of application for procedural programming.

A

Procedural - Educational due to it being easy to learn and widely applicable to many problems.

23
Q

Give an example of application for declarative programming.

A

Artificial intelligence.

24
Q

Give an example of application for functional programming.

A

Machine learning.

25
Q

Give an example of application for Object orientated programming.

A

Simulation and modelling systems.

26
Q

Write down a LMC program that inputs three numbers and calculates their sum.

A

INP
STA 1
INP
STA 2
INP
ADD 1
ADD 2
OUT
HLT

27
Q

What does LDA do

A

Loads the value held at said memory location into the accumulator.

28
Q

What does STA do

A

Stores in the value in the accumulator in the given memory location.

29
Q

What does HLT do

A

Halts the program.

30
Q

What is a dynamic data structure?

A

A data structure that can increase or shrink in size. For example and Linked list or a queue.

31
Q

What is a static data structure?

A

A data structure fixed in size that cannot free up memory while the program is running.

32
Q

What is a linked list?

A

A linked list is a dynamic data structure used to hold a ordered sequence.

33
Q

What is an abstract data type?

A

A logical description of how the data is viewed and the operations that can be performed upon it.

34
Q

What is an array?

A

A series of memory locations holding data of the same type under the same name.

35
Q

What is an attribute in OOP?

A

Attributes, also known as fields, members and properties, are simply variables, low level storage attached to the object.

36
Q

What is a hash table and how does it work?

A

A way to store keys/value pairs.

37
Q

What are programming paradigms?

A

Different approaches to using a programming language to solve a problem

38
Q

State the advantages of procedural programming:

A

-Can be applies to a wide range of problems
-Relatively easy to write and interpret

39
Q

State a use of declarative programming:

A

Any from:

-Expert Systems/Knowledge-based Systems
-Artificial Intelligence

40
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 (most of the time)

41
Q

What is a low level language?

A

Each line represents a single machine code instruction
Much longer than HLL code
Examples include assembly language which uses mnemonics to represent binary instructions
Each type of processor has its own instruction sets available
Code is not portable

42
Q

What are the 11 instructions in LMC?

A

ADD (Add)
SUB (Subtract)
LDA (Load)
BRA (Branch Always)
BRP (Branch if positive)
BRZ (Branch if zero)
INP (Input)
OUT (Output)
HLT (end program)
DAT (data location)
STA (store)

43
Q

Example of inheritance in OOP?

A

car making factory with a parent class of “vehicle” that states that the vehicles will have wheels and engines

sub classes will be “car” or “motorbike” and they will tell you how many wheels you need and what size of engine

44
Q

What is what is overriding in OOP?

A

When a method in a child class is used to replace a method inherited from the parent class

45
Q

How do we access encapsulated data?

A

You must supply methods if you want an object’s internal attributes to be read or altered.

This is done by the use of:
(public) getters, get(),
and (public) setters, set()
getters allow other classes to see the value of an attribute
setters allow the attribute value to be changed
private means the method or attribute is only accessible from within that class. Other classes cannot access them

46
Q

What is encapsulation used for?

A

to hide the values or internal state of an object, preventing direct access by unauthorised parties.

47
Q

What does a private method/attribute mean?

A

private means the method or attribute is only accessible from within that class. Other classes cannot access them

48
Q

What does BRA mean in LMC?

A

BRA (Branch Always)

49
Q

What does BRP mean in LMC?

A

BRP (Branch if positive)

50
Q

What does BRZ mean in LMC?

A

Branch if Zero

51
Q

Advantages of using oop over procedural programming, when developing a computer game.

A

AO1 - Knowledge
- Object-oriented programming makes use of classes (templates) from which objects are made.

  • Object-oriented programming supports inheritance which allows classes to use attributes and methods of parent classes.

AO2 - Application
- OO approach would call on classes per type of player or enemy object

  • Objects made from these classes, so one enemy class may generate many enemy objects, each with different values for their attributes (e.g. speed, energy)

AO3 - Evaulate
OOP is an abstraction of a real world problem, with classes for each type of things to be modelled and objects for each instance of these.

OO has advantages in data security in that encapsulation forces developers/users to use methods (with their built in validation) to access/amend data stored in attributes.