1.2.4 Types of Programming Language Flashcards
Name the 2 categories that programming paradigms can be split into.
Imperative
Declarative
What are imperative programming paradigms?
Code that clearly specifies actions to be performed
Name the 2 imperative programming paradigms.
Procedural
Object-oriented
What are the features of a procedural programming paradigm?
Can be applied to a wide range of problems
Easy to write and interpret
Written as a sequence of instructions
Instructions are carried out sequentially
What are the features of a object-oriented programming paradigm?
Suited to problems that can be broken into reusable components with simillar characteristics
Based on objects formed from classes which have attributes and methods
What are declarative programming paradigms?
States the desired result and programming language determines how best to obtain the result
Details about how result is obtained are abstracted from user
Name the 2 declarative programming paradigms.
Functional
Logic
What is the disadvantage of procedural language?
Not possible to solve all problems or may be inefficient to do so
Name the 4 main programming structures of procedural programming.
Sequence
Selection
Iteration
Recursion
What is assembly language?
Low level language of mnemonics with a one-to-one relationship to machine code
What is the function of ADD?
Adds the value at the given memory address to the value in the accumulator
What is the function of SUB?
Subtracts the value at the given memory address to the value in the accumulator
What is the function of STA?
Stores the value in the accumulator at the given memory address
What is the function of LDA?
Loads the value at the given memory address into the accumulator
What is the function of INP?
Allows the user to input a value which will be held in the accumulator
What is the function of OUT?
Prints the value currently held in the accumulator
What is the function of HLT?
Stops the program at that line, preventing any remaining code from executing
What is the function of DAT?
Creates a flag with a label at which data is stored
What is the function of BRZ?
Branches to the given address if the value in the accumulator is zero
What is the function of BRP?
Branches to a given address if the value in the accumulator is positive
What is the function of BRA?
Branches to a given address no matter the value in the accumulator
How are machine code instructions formed?
Opcode
Operand
What is opcode?
Specifies the instruction to be performed & the addressing mode
What is operand?
A value related to the data on which the instruction is to be performed
What does the addessing mode in the opcode specify?
How the operand should be interpreted
Name the 4 modes of addressing.
Immediate addressing
Direct addressing
Indirect addressing
Indexed addressing
What is immediate addressing?
The operand is the actual value upon which the instruction is to be performed
What is direct addressing?
The operand gives the address which holds the value upon which the instruction is to be performed
What is indirect addressing?
The operand gives the address of a register which holds the address of the value upon which the instruction is to be performed
What is indexed addressing?
An index register stores a value
The address of the value upon which the instruction is to be performed is determined by adding the operand to the index register
What is a class?
A template for an object which defines its state and behaviour
What are the attributes of an object?
Gives an object’s properties
What are the methods of an object?
Describe the actions it can perform
What is an object?
An instance of a class
What is a setter?
A method that sets the value of a given attribute
What is a getter?
A method that retrieves the value of a given attribute
What is encapsulation?
Using getters and setters to ensure attributes of a class cannot be directly accessed/edited but can only be altered by public methods
What is inheritance?
Process in which subclass inherits all methods & attributes of a superclass
Why is polymorphism?
Enables objects to behave differently depending on their class
What is meant by overloading in polymorphism?
Passing different parameters into a method
What is meant by overriding in polymorphism?
Redefining a method so that it functions differently to produce a different output
What are three advantages of OOP?
High level of re usability
Code made more reliable through encapsulation
Makes code easy to maintain and update
What is a disadvantage of OOP?
Not suited to all problem types