Types Of Programming Language Flashcards
What is procedural programming?
- 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
What does it mean if a programming language is Turing complete?
-Can solve all the problems it has been proved computers can solve
What is a low level language?
- 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
What are the 11 instructions in LMC?
ADD SUB LDA BRA BRP BRZ INP OUT HLT (end program) DAT (data location) STA (store)
What is a disadvantage of procedural programming?
-code is re-used a lot and some is redundant
What is a class in OOP?
- 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
What is OOP inheritance?
- 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
Example of inheritance in OOP?
- 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
What is what is overriding in OOP?
When a method in a child class is used to replace a method inherited from the parent class
What is polymorphism?
- 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
What is encapsulation?
- 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 do we access encapsulated data?
- 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
What is encapsulation used for?
- 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
What are the four methods of accessing memory locations in assembly code?
Direct, immediate, indirect and indexed addressing
What is direct addressing?
- The operand represents the memory location of the data we want.
- STA 6 will store the contents of location 6 in the accumulator