1.2.4 Types of Programming Language Flashcards

You may prefer our related Brainscape-certified flashcards:
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
Q

BRZ: instruction, numeric code, and description

A

Branch if zero

7xx

Branch if the contents of the Accumulator is 000 to the instruction in the memory address

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

BRP: instruction, numeric code, and description

A

Branch if positive

8xx

Branch if the contents of the Accumulator is positive to the instruction in the memory address

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

INP: instruction, numeric code, and description

A

Input

901

Input data which is copied to the Accumulator

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

OUT: instruction, numeric code, and description

A

Output

902

Output the contents of the Accumulator

29
Q

HLT: instruction, numeric code, and description

A

Halt

000

End the program

30
Q

DAT: instruction, numeric code, and description

A

Data

-

Used to indicate a location that contains data

31
Q

Where is memory addressing used?

A

In low-level languages

32
Q

What are the 4 types of memory addressing?

A

Immediate addressing #

Direct addressing &

Indirect addressing ~

Indexed addressing []

33
Q

Explain immediate addressing, stating the symbol used in LMC

A

#

Nothing is fetched from memory, the operand contains the data to be used

34
Q

Explain direct addressing, stating the symbol used in LMC

A

&

The operand contains the memory address of where the data to be used is stored in memory

35
Q

Explain indirect addressing, stating the symbol used in LMC

A

~

The operand acts as a pointer towards a table in memory. The address of the data needed is retrieved from that table

36
Q

Explain indexed addressing, stating the symbol used in LMC

A

[]

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
Q

What are the advantages and disadvantages of immediate addressing?

A

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
Q

What are the advantages and disadvantages of direct addressing?

A

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
Q

What are the advantages and disadvantages of indirect addressing?

A

Advantages

  • More space for addresses as isn’t limited by the size of the operand

Disadvantages

  • Slower than direct addressing
40
Q

What are the advantages and disadvantages of indexed addressing?

A

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
Q

Define an Object

A

One member created from a class, with attributes and methods shared between objects

42
Q

Define an attribute

A

Essential features or characteristics of the object created from a class

43
Q

Define a class

A

The overall blueprint of a set of objects

44
Q

Define a method

A

Describes what actions the object can do

45
Q

How do private attributes and methods differ from public ones?

A

Private attributes and methods can only be accessed through getters or setters

46
Q

What does a get and set do?

A

Getter: method which returns the value of a private attribute

Setter: method which lets you change the value of a private attribute

47
Q

What are the advantages of using OOP?

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

What are the disadvantages of using OOP?

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

Define instantiation

A

This is the name for creating an instance of a class

50
Q

Define encapsulation

A

This is the process of causing an attribute to be private, meaning the user is unable to directly edit it

51
Q

Define inheritance

A

A class (subclass) taking on attributes and methods from another class (superclass)

52
Q

Define polymorphism

A

A method or attribute which can take many forms.

This happens when they are overridden by a subclass

53
Q

Define a subclass

A

A child class which takes on the attributes and methods of the linked parent class

54
Q

Define a parent class

A

A parent class with attributes and methods

55
Q

What are the 5 types of programming paradigms?

A

Functional

Object-oriented

Procedural

Low-level

Declarative

56
Q

What are the features of the functional programming paradigm?

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

Define higher-order functions and lazy evaluation

A

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
Q

What are the advantages of the functional programming paradigm?

A
  • Efficient: consists of independent units that can run concurrently
  • Supports lazy evaluation
  • Supports higher-order functions / nested functions
59
Q

What are the disadvantages of the functional programming paradigm?

A
  • Complex as it is rooted in mathematics
  • Recursion is memory expensive
60
Q

What are the features of the object-oriented programming paradigm?

A
  • Parts of the system are categorised as objects, made from classes
  • Classes use set attributes
  • Subroutines are named methods and identified within classes
61
Q

What are the advantages of the object-oriented programming paradigm?

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

What are the disadvantages of the object-oriented programming paradigm?

A
  • The system is often very large and complex
  • Inheritance can have unintended consequences
  • Objects can take up a large amount of memory
63
Q

What are the features of the procedural programming paradigm?

A
  • Uses built-in data types
  • Uses built-in data structures
  • Sequential
64
Q

What are the advantages of the procedural programming paradigm?

A
  • Good for general-purpose programming
  • Lots of references are available
  • No need to know precise CPU details
  • Source code is portable
65
Q

What are the disadvantages of the procedural programming paradigm?

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

What are the features of the declarative programming paradigm?

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

What are the two methods of parameter passing?

A

By value

By reference

68
Q

Explain parameter passing by value

A

A local copy is created when passed

The original remains unchanged

69
Q

Explain parameter passing by reference

A

The location of the data is passed

Changes will be made to the original data