1.2.4 Types of Programming Language Flashcards

(69 cards)

1
Q

Define programming paradigm

A

A style of programming

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

Define procedural programming

A

When every variable, constant, and subroutine is defined separately, with no relationship between them

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

Define object-orientated programming

A

Separate objects are defined with their own subroutines and values

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

Define a constructor

A

A method that creates an object of a particular class with its own attributes

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

Define a static attribute or method

A

Attributes or methods relevant to a whole class

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

Define a non-static attribute or method

A

Attributes or methods that are relevant to only the object

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

What are some features of procedural programming?

A
  • The programmer specifies steps needed to be executed
  • The order of the steps is up to the programmer
  • Statements can be grouped into procedures and functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are some features of object-orientated programming?

A
  • The programmer can design self-contained objects
  • Each object contains methods and the data that is being processed
  • The program is split into smaller units (objects)
  • Objects can be reused and inherited easily
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are some features of assembly language?

A
  • Low-level language
  • Has a one-to-one relationship with machine code
  • Uses mnemonics to represent machine code
  • Specific to a processor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define homogeneous elements

A

All elements have the same data type

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

Define heterogeneous elements

A

Elements can have different data types

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

What is the typical size and explanation of an integer data type?

A

2 or 4 bytes

A whole numerical value

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

What is the typical size and explanation of a real/float data type?

A

4 or 8 bytes

A decimal value

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

What is the typical size and explanation of a string data type?

A

Usually 1 byte per character

A set of character and/or numbers

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

What is the typical size and explanation of a boolean data type?

A

1 bit

Can be one of two values

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

What is the typical size and explanation of a character data type?

A

1 byte

A single letter, digit, or symbol

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

What is the typical size and explanation of a date/time data type?

A

1 byte per date or time

A value that states the date or time:

DD/MM/YYYY or hh:mm:ss

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

What is the typical size and explanation of a currency data type?

A

8 bytes

A real/float value which is told which currency symbol to assign to it

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

What is the basic structure of a 16-bit machine code instruction?

A

Opcode (operation code): basic machine operation (6 bits) and addressing mode (2 bits)

Operand

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

ADD: instruction, numeric code, and description

A

ADD

1xx

Adds the contents of the memory address to the Accumulator

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

SUB: instruction, numeric code, and description

A

Subtract

2xx

Subtracts the contents of the memory address to the Accumulator

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

STA: instruction, numeric code, and description

A

Store

3xx

Stores the contents of the Accumulator to the memory address

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

LDA: instruction, numeric code, and description

A

Load

5xx

Loads the contents of the memory address to the Accumulator

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

BRA: instruction, numeric code, and description

A

Branch always

6xx

Branches to the instruction in the memory address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
BRZ: instruction, numeric code, and description
Branch if zero 7xx Branch if the contents of the Accumulator is 000 to the instruction in the memory address
26
BRP: instruction, numeric code, and description
Branch if positive 8xx Branch if the contents of the Accumulator is positive to the instruction in the memory address
27
INP: instruction, numeric code, and description
Input 901 Input data which is copied to the Accumulator
28
OUT: instruction, numeric code, and description
Output 902 Output the contents of the Accumulator
29
HLT: instruction, numeric code, and description
Halt 000 End the program
30
DAT: instruction, numeric code, and description
Data - Used to indicate a location that contains data
31
Where is memory addressing used?
In low-level languages
32
What are the 4 types of memory addressing?
Immediate addressing # Direct addressing & Indirect addressing ~ Indexed addressing []
33
Explain immediate addressing, stating the symbol used in LMC
# Nothing is fetched from memory, the operand contains the data to be used
34
Explain direct addressing, stating the symbol used in LMC
& The operand contains the memory address of where the data to be used is stored in memory
35
Explain indirect addressing, stating the symbol used in LMC
~ The operand acts as a pointer towards a table in memory. The address of the data needed is retrieved from that table
36
Explain indexed addressing, stating the symbol used in LMC
[] The final address of the data is calculated by adding an offset to a base address. An array has a base address which the operand will point to, and then the base address is incremented to reach each subsequent data value
37
What are the advantages and disadvantages of immediate addressing?
Advantages * Useful when dealing with short constants * Very fast Disadvantages * Not useful with variables or long values, since the data is restricted by the size of the operand
38
What are the advantages and disadvantages of direct addressing?
Advantages * Fast Disadvantages * Slower than immediate mode * The space for the address is limited by the size of the operand * Doesn't allow for re-locatable code
39
What are the advantages and disadvantages of indirect addressing?
Advantages * More space for addresses as isn't limited by the size of the operand Disadvantages * Slower than direct addressing
40
What are the advantages and disadvantages of indexed addressing?
Advantages * Fast * Great for manipulating data structures * If the array is relocated, only the base address needs to change Disadvantages * Slower than direct addressing, since calculations need to be performed
41
Define an Object
One member created from a class, with attributes and methods shared between objects
42
Define an attribute
Essential features or characteristics of the object created from a class
43
Define a class
The overall blueprint of a set of objects
44
Define a method
Describes what actions the object can do
45
How do private attributes and methods differ from public ones?
Private attributes and methods can only be accessed through getters or setters
46
What does a get and set do?
Getter: method which returns the value of a private attribute Setter: method which lets you change the value of a private attribute
47
What are the advantages of using OOP?
* Prewritten classes support code reuse * Classes can be easily extended with child classes * Easy to manipulate, as highly modular * Encapsulation can provide high levels of protection for data
48
What are the disadvantages of using OOP?
* A system relying on message passing can be less effective * Inheritance could use unwanted attributes or methods to be acquired * Objects can take up a relatively large amount of memory
49
Define instantiation
This is the name for creating an instance of a class
50
Define encapsulation
This is the process of causing an attribute to be private, meaning the user is unable to directly edit it
51
Define inheritance
A class (subclass) taking on attributes and methods from another class (superclass)
52
Define polymorphism
A method or attribute which can take many forms. This happens when they are overridden by a subclass
53
Define a subclass
A child class which takes on the attributes and methods of the linked parent class
54
Define a parent class
A parent class with attributes and methods
55
What are the 5 types of programming paradigms?
Functional Object-oriented Procedural Low-level Declarative
56
What are the features of the functional programming paradigm?
* Designed around using mathematical functions, conditional expressions, and recursion * Supports higher-order functions and lazy evaluation * Doesn't support flow controls (e.g. loops/conditionals) * Supports abstraction, encapsulation, inheritance, and polymorphism
57
Define higher-order functions and lazy evaluation
Higher-order functions: functions that call other functions as arguments or in some way Lazy evaluation: an expression is only evaluated when it is needed
58
What are the advantages of the functional programming paradigm?
* Efficient: consists of independent units that can run concurrently * Supports lazy evaluation * Supports higher-order functions / nested functions
59
What are the disadvantages of the functional programming paradigm?
* Complex as it is rooted in mathematics * Recursion is memory expensive
60
What are the features of the object-oriented programming paradigm?
* Parts of the system are categorised as objects, made from classes * Classes use set attributes * Subroutines are named methods and identified within classes
61
What are the advantages of the object-oriented programming paradigm?
* Often easier to think in objects than procedurally * Promotes and supports code reuse * Classes are highly modular and easy to maintain * Encapsulation provides data protection
62
What are the disadvantages of the object-oriented programming paradigm?
* The system is often very large and complex * Inheritance can have unintended consequences * Objects can take up a large amount of memory
63
What are the features of the procedural programming paradigm?
* Uses built-in data types * Uses built-in data structures * Sequential
64
What are the advantages of the procedural programming paradigm?
* Good for general-purpose programming * Lots of references are available * No need to know precise CPU details * Source code is portable
65
What are the disadvantages of the procedural programming paradigm?
* Many different types of languages, meaning you need to specialise * Need to be precise and knowledgeable about the language, meaning debugging and coding can take a while
66
What are the features of the declarative programming paradigm?
* A programmer writes statements that specify the problem to be solved * The software will seek an answer to a goal by interrogating a database with facts and rule * Doesn't function sequentially, so can backtrack while checking criteria
67
What are the two methods of parameter passing?
By value By reference
68
Explain parameter passing by value
A local copy is created when passed The original remains unchanged
69
Explain parameter passing by reference
The location of the data is passed Changes will be made to the original data