Types of Programming Language Flashcards

1
Q

what is a paradigm

A

a way of looking / thinking about something
- a standard
- a certain perspective
- a set of ideas

A new paradigm in business could mean a new way of reaching customers and making money

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

what is a programming paradigm

A

a certain approach we might have to programming

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

Which assembly language mnemonic is used to branch if the accumulator is greater than or equal to zero?

A

BRP

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

Which assembly language command will always change the value in the program counter?

A

BRA

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

Which assembly language mnemonic is used to subtract a variable from the accumulator?

A

SUB

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

Which of these is a feature of object orientated programming languages?
Select the most appropriate answer.

Programs are structured into procedures and/or functions

Uses symbolic address as labels to reference locations of data in memory

Commands have a one-to-one relationship with machine code

Programs are structured into classes, methods and instances

A

Programs are structured into classes, methods and instances

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

What keyword should be placed before an attribute or method in pseudocode if we want to make sure it can be accessed by other objects?

A

PUBLIC

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

Which of these is a feature of a low level programming language?
Select the most appropriate answer.

Source code is easier to write

Large number of instructions

Translates to many different machine types

Source code is harder to write

A

Source code is harder to write

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

What does this line of object orientated pseudo-code do?
CLASS teacher INHERITS Person

A

Creates a new subclass called teacher which inherits from the person class

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

Which is the correct definition of ‘direct addressing’?
Select the most appropriate answer.

The operand is an address to a memory location containing an address
The address is the base address plus the value in the index register
The operand is a value to be used by the instruction
The operand is the address to use by the instruction

A

the operand is the address to use by the instruction

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

indexed addressing

A

modifies the address by the addition of a number held in the index register

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

object

A

an instance of class

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

subclass

A

a class that extends another class. the subclass inherits the methods and attributes of the class it extends

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

method

A

a subroutine contained within a class / object designed to perform a particular task on the data within the object

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

superclass

A

a class that has been extended by another class

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

attribute

A

a single item of data within a record or object

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

define low level language (2 marks)

A

a language which is close to machine code

one mnemonic translates to one machine code instruction

a language that is most suited to the machine architecture

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

state three advantages of programs written in Assembly language (3 marks)

A

one to one relationship with machine code

can make use of special machine-dependent instructions
e.g. in the instruction set for the chip

translated program requires less memory

code can execute more quickly

easier to optimise

can work directly on memory locations

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

explain inheritance

A

a class has all the attributes and operations/methods …

…of its superclass…

…and may also have attributes and operations/methods of its own

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

class

A

a class is a type definition

a class has attributes and methods

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

A product manager at ‘Better Solutions Ltd’ oversees a team of developers who program in both high-level and low-level languages.

Justify why the team may sometimes choose to write programs in either a high-level or low-level language. (6 marks)

A

high-level language
- easier to learn / understand code …
- programs can often be developed faster
- programs are prone to less errors / bugs
- programs are easier to debug / maintain / improve
- easier to find programmers who specialise in high-level language
- some high-level languages are specifically designed to solve certain types of problems

low-level language
- code is optimised for a specific architecture
- code can execute extremely fast
- the assembled code occupies less space in the memory than the machine code equivalent produced by a high level complier
- individual statements are able to manipulate / control specific hardware components

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

types of programming paradigms

A

object-oriented programming (OOP)
imperative programming
declarative programming
procedural programming

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

where do all these paradigms come from

A

high level language
assembly language
machine code

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

low-level vs high-level languages diagram

A

HLL OO & visual languages
HLL HL language: C, Fortran, Pascal
LLL assembly language
LLL machine language
LLL hardware

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
high level language
uses more human readable statements and constructs each line of code will translate to multiple lines of machine code uses an assembler or complier to translate into machine code much more complex and further abstracted from machine code
26
assembly language
uses short codes called mnemonics e.g. ADD, R1, R2 or INP X for each mnemonic there is one sequence of 1s and 0s they are slightly more abstracted and easier to read / write an assembler is used to translate from assembly language to machine code
27
machine code
we use 1s and 0s to represent the electrical signals within the computer it's the closest to what is happening on the computer which makes it the least abstract
28
types of high level languages
imperative - focus is on describing how a program operates - made up of statements that will change the programs state using sequence, selection and iteration declarative - focuses on WHAT the program should accomplish
29
examples of declarative
logic functional
30
examples of imperative
object oriented procedural
31
imperative high level languages
object oriented - looking at the word as objects which have attributes and methods example: car or plane or person procedural - programs are built from one or more subroutines
32
Procedural VS OOP features
procedural - uses sequences, selection and iteration OOP - uses sequence, selection and iteration BUT also have inheritance, objects, classes and encapsulation
33
Procedural VS OOP data
procedural - data is stored in local or global variables and passed using parameters to other parts of the program OOP - data can be private to each object, stored in attributes which are retrieved and changed through methods. this concept is encapsulation
34
procedural VS OOP program structure
procedural - procedures and functions OOP - classes, methods and instances
35
Procedural VS OOP program logic
Procedural - program flows through calls to procedures and functions OOP - objects are created and the objects methods are called when they are needed. Objects interact with other objects whilst the program is still running
36
why do we need different programming paradigms
different problems need different approaches a 3D game for example will be better suited to OOP as the character, enemies, obstacles, backgrounds etc can be different objects simple quizzes might be suited to procedural languages as OOP would add extra complexity
37
which paradigm for making a mario cart
OOP
38
which paradigm for creating a quiz
procedural
39
what paradigm for designing a website
declarative - HTML
40
what paradigm for querying a database
Declarative - SQL
41
features of procedural programming
program control and flow pre-defined functions - sequence - selection - iteration local variables global variables modularity - procedures - functions passing parameters
42
procedural programming
the language tells the computer what to do by giving step by step instructions features of procedural languages: sequence, selection and iteration code is created in a modular way: Procedure and functions
43
global variables
global variables can be seen in the whole program, every function and procedure
44
local variables
local variables will only be able to be seen in their function on procedure. This is called the SCOPE of the variable
45
passing parameters
sum (a, b) public static int sum (int start, int end) { int s; s = 0; for (int i = start; i <= end; i++) s += i; return s; } a and b are arguments they are passed to parameter variables this is parameter "passing" the parameter variables are int start and int end a is passed into int start b is passed into int end
46
assembly language - low level language
the first languages were machine code languages where the programmers entered binary combinations very difficult to read and write it would be easier to have readable words lead to the development of assembly languages which use mnemonics - simple letter codes like ADD, SUB, LDA there is a one-to-one relationship with the mnemonics and the binary instruction the mnemonics are specific to the machines CPU e.g. Intel, ARM, AMD, Qualcomm etc. They are non portable
47
assembler
used to translate the assembly code into machine code
48
the instructions is broken up into two parts ...
opcode and operand
49
opcode
this is the action to be performed e.g. ADD, LOAD
50
operand
this is the data or address for the opcode to act on e.g. it could be loading data from an address OR it could be data to add
51
advantages of machine code and assembly language
assembly language is quick to execute as each mnemonic maps onto one machine code can access system features without a separate interface, which would add more time very powerful as you are interacting directly with the machine. You're in control without any extra features a high level language might not do smaller programs - require less memory
52
disadvantages of machine code and assembly language
each code is dependant on the machine hard to code and time consuming bug prone as there are no debugging features hard to understand need good understanding of hardware
53
why are assembly languages used for embedded systems
have limited number of tasks size restriction with limited resources e.g. storage and cooling program needs to make efficient use of the processor, storage and power assembly languages can create optimised programs and efficient
54
why are assembly languages used for device drivers
device drivers need to interact with peripherals they need them to perform in a specific way assembly languages allow for precise control of hardware the programs run quickly and are efficient
55
mnemonic > instruction (alternative mnemonics accepted) (there's 11)
ADD > Add SUB > Subtract STA > Store (STO) LDA > Load (LOAD) BRA > Branch always (BR) BRZ > Branch if zero (BZ) BRP > Branch if positive (BP) INP > Input (IN, INPUT) OUT > Output HLT > End program (COB, END) DAT > Data location
56
what are the simple letter codes used in assmebly langauge
mnemonics
57
what converts assembly langauge to machine code?
assembler
58
memory addresses
The CPU accesses addressed locations in main memory. there are different modes locations can be addressed
59
modes of addressing memory
immediate direct indirect indexed
60
immediate addressing
ADD 10 0001 1010 take the following instruction above the 0001 would mean ADD on the instruction set the operand part would actually mean the value NOT address The value here in denary is 8 4 2 1 1 0 1 0 so 8+2 = 10 The actual instruction is ADD 10 The operand specifies a value. This value will be used in the operation
61
direct addressing
ADD 10 0001 1010 take the following instruction above the operand part would actually mean the address of the value to use we know 1010 = 10 as 8 + 2 is 10 we would go to the address in memory and add the value inside it the address 1010 in RAM is 0000 1110 so we add the value In this case it's 128 64 32 16 8 4 2 1 0 0 0 0 1 1 1 0 so 8 + 4 + 2 = 14 the operand specifies the address of a memory location. The contents of this memory location will be used in the operation
62
indirect addressing
ADD 10 0001 1010 take the following instruction above the operand specifies the address of a memory location which holds the address of another memory location. the contents of the second location will be used in the operation we know 1010 is the 10th address in RAM and it is 0000 1110, we know the denary value of that 8 digit code is 14 so we go to address 14 and use the value there address 14 = 1010 1001 128 64 32 16 8 4 2 1 1 0 1 0 1 0 0 1 so 128 + 32 + 8 + 1 = 169
63
indirect addressing - whats the point
it means we can address MORE locations
64
indexed addressing
*****COME BACK TO IT*********
65
write psuedocode for the following class Node Attributes Data (string) Methods getData() setData()
Class Node{ private data; public procedure new(string d){ data = d; } public void setData(string newData){ data = newData; } public string getData(){ return data } }
66
instantiate a new object called listItem with the data "Banana"
Class Node{ private data; public procedure new(string d){ data = d; } public void setData(string newData){ data = newData; } public string getData(){ return data } } listItem = new Node(“Banana”)
67
which address mode allows you to access more addresses in memory
Indirect: The operand specifies the address of a memory location which holds the address of another memory location. The contents of the second location will be used in the operation.​
68
Which address mode is used for applying the same instructions over an array?
Indexed: The operand specifies the address of a memory location. The contents of the index register, which is a dedicated register in the CPU, will be added to the address to determine a second address. The contents of the second location will be used in the operation.​
69
what are the two other address modes
Immediate: The operand specifies a value. This value will be used in the operation. Direct: The operand specifies the address of a memory location. The contents of this memory location will be used in the operation.
70
inheritance with badger class
Badger Attributes Name: String Age: Integer isMale: Boolean Colour: String Methods getName() setName() getAge() setAge() getGender() setGender() getColour() setColour() This is a badger class It’s very generic and doesn’t fit We can use Inheritance to reuse the code (the attributes and methods) from the badger class and make a more specific class for either a Honey badger or European badger or American badger. This doesn’t affect the original badger class, just extends from it Both the Honey Badger and European Badger inherit the attributes and methods from the Badger class. They can also add their specific attributes and methods Badger is know as the parent class and the Honey Badger and European Badger is known as the child classes. They can still access the attributes and methods from their parent class If you want a inherited method to do something different to the parent class, you can override it in the child class PARENT CLASS Public string getName(){ Return name } CHILD CLASS Public string getName(){ Return ”I am +” name + “a honey badger” } OR Public string getName(){ Return ”I am +” name + “a European badger” } If I want to use the overridden method you would write: hBadger.getName() If you want to use the super class method you would write: hBadger.super.getName()