1.2.4 Types of Programming Language Flashcards

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

what is a paradigm?

A

to describe an example of a way of doing things

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

what does Turing complete mean?

A

a computer language that can solve all the problems a computer is able to solve

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

why do we need different paradigms?

A

some problems are better suited to being solved using a certain paradigm

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

what are the characteristics of machine code?

A
  • least abstract
  • closest to what actually happens in computer
  • programs in 1s and 0s
  • translated into electrical signals
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are the characteristics of assembly language?

A
  • uses mnemonics
  • each mnemonics matches a specific binary code
  • one to one relationship
  • translated by an assembler
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what are the characteristics of high-level languages?

A
  • can go further than machine and assembly
  • one-to-many relationship - each instruction is equivalent to many lines of machine code
  • so much more complex so are high level
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are the two categories of high level languages?

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

what are the characteristics of imperative languages?

A
  • uses statements which change a program’s state (eg. sequence, selection, iteration)
  • consists of commands for a computer to complete
  • focus on how a program operates
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what are the characteristics of a declarative language?

A
  • focuses on what the program should accomplish
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what are the two paradigms under imperative languages?

A
  • object oriented
  • procedural
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the characteristic of procedural programming?

A

program is builds from one or more subroutines

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

what is the characteristic of object oriented programming?

A

modular approach to programming

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

what are the advantages of machine and assembly?

A
  • assembly has the same efficiency as machine as it is a one to one relationship
  • it can produce very precise, locally optimised and efficient code
  • it provides direct access to system level features - improves speed
  • complete control of code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what are the disadvantages of machine and assembly?

A
  • machine dependant and very hard to port
  • rare to find efficient assembly coders
  • very tedious and prone to bugs
  • difficult to understand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what features do procedural languages have?

A

sequence, selection, iteration

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

what features do oop have?

A

sequence, selection, iteration
+ inheritance, objects, classes and encapsulation

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

how is data stored in procedural languages?

A

local or global variables
accessible through parameter passing

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

how is data stored in oop?

A

attributes and concealed from other parts of program through encapsulation

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

what is the program structure for procedural languages compared to oop?

A
  • procedures and functions
  • classes, methods and instances
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what is the program logic for procedural languages compared to oop?

A
  • expressed in a series of procedure calls
  • based on models and behaviours
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

how is the code laid out in procedural languages?

A
  • series of statements such as sequence, selection and iteration
  • developed in a modular way with subroutines
21
Q

how is assembly code converted to machine code?

A

translated by an assembler

22
Q

what are the mnemonics for add, subtract store and load?

A

ADD
SUB
STA
LDA

23
Q

what are the mnemonics for branching instructions?

A

BRA
BRZ
BRP

24
Q

what are the mnemonics for input, output, end program and data location?

A

INP
OUT
HLT
DAT

25
Q

what does the instruction register hold?

A

the first digit of the instruction read from memory = opcode

26
Q

what does the address register hold?

A

2nd and 3rd digits of the instruction = operand

27
Q

what are labels in LMC?

A

any characters which are not mnemonics
refer to addresses in RAM
if label is before DAT, it represents the address
if the label is after DAT, it is calling on the label

28
Q

what is immediate addressing?

A

the value in the address part of the instruction is actually the value to be used, so memory does not need to be searched to find the required value

29
Q

what is direct addressing?

A

the value in the address part of the instruction is a reference to the address in memory where the required value is located

30
Q

what is indirect addressing?

A

the value in the address part of the instruction is a reference to a memory location that contains the address in memory where the required value is located

31
Q

why is indirect addressing used?

A

it means larger address ranges can be used to reference data and instructions

32
Q

what is indexed addressing?

A

uses an index register (IR)
takes the operand value and adds IR value then goes to this address in memory.
IR value increment to get the next memory address directly after the previous one

33
Q

what is the structure of a class?

A

name
attributes (like variables)
methods (code to access or change attributes)

34
Q

what is a class?

A

a blueprint (template) used to set or define what attributes and methods an object of a certain type should have

35
Q

why are classes good?

A

it becomes easy to reuse the class and create hundreds of objects of that class

36
Q

what is instantition?

A

the process of creating an object from a class template

37
Q

how do you instantiate a new object of a class?

A

use the keyword NEW

38
Q

what is a constructor method?

A

a special method within the class that runs when an object of that class type is created

39
Q

what does the constructor method do?

A

takes the parameters passed into the object and sets its local attributes to their initial values

40
Q

what is inheritance?

A

when a subclass is defined which uses/calls on the attributes and methods of another class and then adds additional attributes and methods which are required for this subclass

41
Q

what is overriding?

A

using a method of the same name in a subclass that contains more specific code relevant to that class
- occurs automatically when there are 2 methods of the same name at different places of the class tree

42
Q

how can overriding be prevented?

A

use super<dot> (eg super. )</dot>

43
Q

how is inheritance done in code?

A

declare class and say which class it inherits from:

class <class> inherits <superclass></superclass></class>

44
Q

what is encapsulation?

A

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

45
Q

how are encapsulated attributes accessible or changable?

A

only via the methods provided by the object

46
Q

which attributes are encapsulated?

A

private attributes

47
Q

what is polymorphism?

A

something that occurs in several forms

giving an action one name that is shared up and down an object hierarchy, with each object in the hierarchy implementing the action in a way appropriate to itself

48
Q

what are the types of polymorphism?

A

static
dynamic

49
Q

what is static polymorphism?

A

allows you to implement multiple methods of the same name - but with different parameters - within the same class
= method overloading

50
Q

what are the conditions for static polymorphism?

A
  1. need to have a different number of parameters
    OR
  2. the types of parameters needs to be different
    OR
  3. they need to expect the parameters in a different order
51
Q

why is inheritance with methods of the same name in different classes polymorphism?

A

the two methods share the same name but provide different functionality depending on whether they are implemented by the superclass or subclass