TYPES OF PROGRAMMING LANGUAGE Flashcards

1
Q

What are the 2 types of programming language?

A
  • high level languages
  • low level languages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some examples of low level languages?

A
  • machine code
  • assembly language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is used to translate assembly language into machine code?

A

an assembler

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

LMC instruction set (11)

A
  • ADD (add)
  • SUB (subtract)
  • STA (store)
  • LDA (load)
  • BRA (branch always)
  • BRZ (branch if 0)
  • BRP (branch if positive)
  • INP (input)
  • OUT (output)
  • HLT (end program)
  • DAT (data location)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 4 methods of addressing?

A
  • immediate
  • direct
  • indirect
  • indexed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is immediate addressing?

A
  • value in the address part of the instruction is the actual value to be used (so memory does not need to be searched to find that required value)
  • eg: ADD 10 literally means add 10 (not add value stored in memory address 10)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is direct addressing?

A
  • value in the address part of the instruction refers to the address in memory where the required value is located
  • eg: ADD 10 means add the value that’s located in memory address location 10
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is indirect addressing?

A
  • value in the address part of the instruction refers to the memory location that contains the address in memory where the required value is located
  • this is useful as it means larger address ranges can be used to reference data and instructions
  • eg: ADD 10 means add the value that’s located in the memory address location that was stored in memory address location 10
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is indexed addressing?

A
  • a method where the final memory address is calculated by adding a constant value (the offset) to the contents of an index register
  • this allows efficient access to data stored in consecutive memory locations, such as arrays
  • eg: the index register contains the value 5. the instruction ADD 10 refers to memory location 10 + 5 = 15. the CPU retrieves the value stored at memory location 15 and adds it to the accumulator (or the current working register)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the main programming paradigms?

A
  • low level languages,
  • object-orientated languages
  • declarative languages
  • procedural languages
  • functional languages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are Turing complete languages?

A

programming languages that can solve all problems that a computer is able to solve (most programming languages in most programming paradigms)

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

Why do we need different programming 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
13
Q

What are the 2 types of high level languages?

A
  • imperative (focus on describing how a program operates)
  • declarative (focus on describing what the program should accomplish)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the 2 main paradigms that fall under imperative languages?

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

What are features of procedural languages?

A
  • variables
  • constants
  • sequence
  • selection
  • iteration
  • subroutines
  • string handling
  • operators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is object-oriented programming (OOP)?

A

a programming paradigm that attempts to capture or group info into structured items (objects)

17
Q

What is a class?

A

defines what attributes and methods an object of a certain type should have (template so every object made from that class has the same attributes

18
Q

What are the 3 sections of a class diagram?

A
  • class name
  • attributes (all info shared by any any object of this class type)
  • methods (code associated with a class that allows you to change/access attributes)
19
Q

What is instantiation?

A

the process of creating an object from a class template

20
Q

Example of code to define a class (pseudocode)

A

class (class name) (eg: toyTank)
private colour
private name

public procedure new (givenColour , givenName)
    colour = givenColour
    name = givenName
end procedure

public procedure getColour()
    print("my colour is " + colour)
end procedure 

public procedure getName()
    print("my colour is " + name)
end procedure 

public procedure setColour(newColour)
    colour = newColour        
end procedure 

public procedure setName(newName)
    name = newName        
end procedure  endclass
21
Q

Example of code to create objects from the class template (pseudocode)

A

(objectone) = new (class name)(“(colour)”, “(name)”)
(objecttwo) = new (class name)(“(colour)”, “(name)”)
(objectthree) = new (class name)(“(colour)”, “(name)”)

eg:
tankone = new toyTank(“blue”, “trevor”)
tanktwo = new toyTank(“red”, “tim”)
tankthree = new toyTank(“green”, “tony”)

22
Q

Example of code to get and set object names and colours (pseudocode)

A

(objectone).getName
(objectone).setName(“(name)”)
(objectone).getColour
(objectone).setColour(“(colour)”)

eg:
(tankone).getName
(tankone).setName(“tom”)
(tankone).getColour
(tankone).setColour(“yellow”)

23
Q

What is inheritance?

A
  • a way of creating classes that share most of the same features as another class
  • subclass inherits details of superclass and adds additional attributes and methods required
24
Q

Code for inheritance (pseudocode)

A

class (subclass name) inherits (superclass name)
etc….
endclass

25
Q

What is encapsulation?

A

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

26
Q

What is encapsulation used for?

A
  • used to hide values/internal state of an object, preventing direct access by unauthorised parties
  • helps keep data related to an object safe (it can’t be accidentally altered by another part if the program without using the code provided in the methods)
27
Q

What is polymorphism?

A

where a single method takes different forms depending on the class that’s using it

28
Q

What are the 2 main types of polymorphism in OOP?

A
  • static
  • dynamic
29
Q

What is static polymorphism?

A

static polymorphism allows you to implement multiple methods of the same name but with different parameters within the same class (known as method overloading)

30
Q

In what ways must the parameter sets differ for static polymorphism?

A
  • must differ in at least one of these ways:
  • each method needs to have a diff no. of parameters (eg: 1 method takes 2 parameters while another takes 3)
  • the types of parameter need to be different (eg: 1 method accepts a string the other accepts an integer)
  • parameters need to be accepted in diff orders (eg: 1 method accepts a string then an integer and another accepts an integer then a string)
31
Q

What is dynamic polymorphism?

A

both methods share the same name and parameters but they provide different functionality depending on whether they’re implemented by the superclass or the subclass