1.2.4 - Types of programming languages Flashcards
What are procedural languages?
1) High-level, 3rd generation, imperative languages.
2) Use sequence, selection and iteration.
3) Program gives a series of instructions in a logical order line by line to state what to do and how to do it.
4) Program statements are in blocks called procedures and functions.
5) Break the solution down into subroutines which are rebuilt and combined to form a program.
6) Statements are in a specific order i.e. sets tasks to be completed in a specific way.
7) Logic of program is given as a series of procedure calls.
8) Examples include: VB.NET and Python.
What is assembly code?
Is a machine-oriented language related closely to the specific design of the computer being programmed.
Is a LLL but higher level than machine code i.e. each instruction is generally translated into 1 machine code instruction.
Uses descriptive names for data stores. Uses mnemonics for instructions.
Uses labels for addresses to allow selection.
May use macros. Is translated by an assembler.
Easier to write than machine code, but more difficult than HLL.
What are 4 different addressing modes?
Immediate addressing
Direct addressing
Indirect addressing
Indexed addressing
What is immediate addressing?
Used in assembly language.
Uses data in address field as a constant.
Data in the operand is the value to be used by the operator e.g. ADD 45 adds the value 45 to the value in the
ACC.
In summary reads the opcode, to see what to do, and then the operand is what value is stored.
What is direct addressing?
The opcode is the instruction still but the operand is the address of the value that is going to be stored.
For example: ADD 1 would add the value at address 1, to the ACC.
The number of memory locations available that can be addressed is limited by the size of the address field.
Code is not relocatable so uses fixed memory locations.
What is indirect addressing?
Similar to direct addressing but the operand is the address of the address for the value (E.g. in ADD 23, if address 23 stores 45, address 45 holds the number to be used)
Used to access library routines.
Increases the size of the address that can be used allowing a wider range of memory locations to be accessed.
What is indexed addressing?
Uses the Index Register to calculate the address. If i have ADD 2, it will use the address of 2 plus whatever is in the index register to find the value.
Allows efficient access to a range of memory locations by incrementing the value in the IR e.g. used to access an
array
What is Object-Oriented Programming (OOP)?
In OOP, program components are split into small units called objects/classes which are used by and interact with other objects to build a complex system.
Most programs nowadays are built using OOP at least to some extent.
Examples of OOP languages include: Java, C++ and C#
What is a class in OOP?
A template defining methods and attributes used to construct a set of objects that have state and
behaviour.
What is an object in OOP?
These are program building blocks. They are self-contained instances of classes based on real-world
entities which contain attributes and methods.
What is a method in OOP?
Is a program code subroutine that forms the actions an object can carry out.
What is an attribute?
Is a data value, stored in a variable associated with an object.
What is a constructor?
The method used to describe how an object is created and sets the attributes.
What are 3 fundamental concepts in object-oriented programming (OOP)
Inheritance
Encapsulation
Polymorphism
What is inheritance in OOP?
Is when a derived class inherits all the methods and attributes of its parent class/superclass
The inheriting class may override some of these methods and attributes and may also have additional extra
methods and attributes of its own.
This means that one class can be coded and used as the base for similar objects which will save time.
Essentially the class is reusable