1.2.4 Types of Programming Language Flashcards

1
Q

Define and give the benefits of the procedural programming paradigm

A

Relatively simple to learn for beginners

Applicable to a wide variety of problems.

Uses the programming constructs of sequence, branching, iteration, and recursion.

Uses modular techniques to split large programs into manageable chunks.

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

Define and give the benefits of the object-oriented programming paradigm

A

Uses features such as classes (methods and attributes), objects, encapsulation, polymorphism and inheritance

Can abstract details of implementation away from the user

Code/classes are reusable & programs are simpler to maintain.

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

Define and give an example of the declarative programming paradigm

A

Languages such as SQL

Uses statements that describe the problem to be solved, and the language implementation decides the best way of solving it.

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

Define the assembly/low-level programming paradigm

A

Languages such as Assembly Language

Uses Mnemonics to represent Opcodes

Mainly hardware oriented

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

List the 11 mnemonics used in LMC

A

ADD
SUB

STA
LDA

BRA
BRP
BRZ

INP

OUT

HLT

DAT

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

Write the LMC code to take two inputs and output the biggest of them.

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

State the four addressing modes

A

Immediate
Direct
Indirect
Indexed

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

Describe the immediate addressing mode

A

LDA 12 – Loads 12 into the accumulator

The operand is the value to be used

Doesn’t look for the value in RAM as the value is in the instruction.

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

Describe the direct addressing mode

A

LDA 4 would load the contents of location 4

The operand holds the memory location of the value to be operated on.

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

Describe the indirect addressing mode

A

LDA 4 would load the address held in location 4 and then load the value in the address that was found using location 4. (Bounces around…)

Operand is the memory location holding a value representing the memory location to be used

Enables a larger range of addressable locations.

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

Describe the indexed addressing mode

A

Index register = 3 + LDA 4 - Would load the data at location 7

Operand is added to the contents of the ‘Index Register’ to get the memory location of the value needed.

Used to access an array whose elements are in successive memory locations.

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

Describe a class

A

A template defining methods and attributes, used to make objects.

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

Describe an object

A

An instance of a class is called an object and is created using a constructor (new)

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

Describe a method

A

The actions that can be performed by an object; for example, get a position on a game board.

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

Describe an attribute

A

Each object will have its own public or private attributes.

The attributes of a player in a game of Monopoly might include its PlayerID and money.

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

Define encapsulation and the benefits of using it.

A

Attributes are set as private so they can only be accessed and changed via public methods

Uses ‘set methods’ to modify the value of a private attribute

Uses ‘get methods’ to retrieve the value of a private attribute

Prevents unexpected changes to attributes having unforeseen consequences.

17
Q

Define inheritance

A

The child class has its attributes and methods, but it also gets all attributes and methods from the parent class.

Uses the keyword ‘Inherits’

18
Q

Define Polymorphism (overriding)

A

Code can be written that can handle different objects in the same way, this reduces the amount of code.

Using methods with the same name in a subclass as in a parent class is called overriding, which is a type of polymorphism.

Overriding allows a sub-class to use its method rather than that of the parent.

19
Q

Write a constructor for a Player class with the attributes shown:

PlayerID, boardPosition, money

All objects have a money value of 2000.

A

public procedure new(thePlayerID, thePosition)
playerID = thePlayerID
boardPosition = thePosition
money = 2000
endprocedure

20
Q

Write the line to instantiate an object called “Boot” at position 10 using the Player class with the attributes PlayerID, boardPosition, money

All objects have an unchangeable money value of 2000.

A

Boot = new Player(“Boot”, 10)