Types Of Programming Language Flashcards

1
Q

What is procedural programming?

A
  • Form of imperative programming. Tell computer how to solve problem
  • Tell the computer steps we want the computer to go through to solve a problem
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does it mean if a programming language is Turing complete?

A

-Can solve all the problems it has been proved computers can solve

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 11 instructions in LMC?

A
ADD
SUB
LDA
BRA
BRP
BRZ
INP
OUT
HLT (end program)
DAT (data location)
STA (store)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a disadvantage of procedural programming?

A

-code is re-used a lot and some is redundant

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

What is a class in OOP?

A
  • logical grouping of data and functions
  • logical connection between the contents of the class
  • based on objects in the real world or concepts like HTTPReequest
  • blueprints for creating objects. A manual for constructing a certain object, telling it what attributes and methods it should have
  • one class can create many objects
  • can be re-used in other programs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is OOP inheritance?

A
  • a child class derives the data and behaviour of a parent class
  • if we want to change the base data or behaviour we only have to change it in the parent class and propagate to the child classes
  • allows us to create a child class that has all the methods and attributes of its parent as well as attributes and methods of its own
  • the children are a “type of” the parents main class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
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

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

What is polymorphism?

A
  • methods behave differently according to the context in which they are used
  • eg; when we have a polymorphic array that contains objects of different classes but that inherits from the same parent class. So voicecontrol() does the same thing on all smartphones but is implemented differently on all of them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is encapsulation?

A
  • the mechanism by which we can restrict access to some of the components that comprise an object
  • the objects internal representation cannot be seen from outside its definition
  • the pattern of making attributes in a class private but allowing them to be changed and accessed through public methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do we access encapsulated data?

A
  • use getters, get(), and setters, set()
  • getters allow other classes to see the value of an attribute
  • setters allows the attribute value to be changed
  • private means the method or attribute is only accessible from within that class. Other classes cannot access them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is encapsulation used for?

A
  • we can ensure that the internal data cannot be accidentally set to an inconsistent or invalid stat
  • isn’t there to stop malicious attempts to change attributes
  • there to reduce the chance of mistakes occurring through attributes being altered in an unforeseen way by other objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the four methods of accessing memory locations in assembly code?

A

Direct, immediate, indirect and indexed addressing

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

What is direct addressing?

A
  • The operand represents the memory location of the data we want.
  • STA 6 will store the contents of location 6 in the accumulator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Immediate addressing?

A
  • the operand is the actual value we want

- STA 6 means store 6 in the accumulator

17
Q

What is indirect addressing?

A
  • the operand is the address of the data we want
  • useful as we have a limited number of bits we can use for the operand (opcode takes up a few)
  • we use all the bits in the memory location for an address, so we can access a much wider range of memory locations
  • eg: location 6 contains 85 and location 85 contains 21. STA 6 will load 21 into the accumulator
18
Q

What is indexed addressing?

A
  • one of the registers in the CPU is the index register
  • the value given is the base address. This is then added to the value in the index register to give the memory location. The value from this memory address is loaded into the accumulator
  • by incrementing the index register it is possible to iterate effectively through an array
19
Q

What are properties and what are methods in OOP?

A

Eg; Phone is the object
Properties = make, model, colour (description)
Methods = sends/receives calls, check voicemail (what it does)

20
Q

What is a benefit of OOP over procedural languages?

A

-allows more complex functionality but with less code