Programming Flashcards

1
Q

Why is it necessary to have a variety of programming languages?

A
  • different languages suit different jobs

- developers prefer certain languages

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

computer program

A

a series of instructions that are executed one after another.
follow the pattern: INPUT -> PROCESS -> OUTPUT

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

3 programming constructs

A

sequence, selection, iteration

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

Sequence

A

do one statement after another in the correct order

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

Selection

A

do a set of statements based on conditions allow your code to make choices- otherwise known as branching

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

iteration

A

do a set of statements again and again (looping)

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

count controlled loops

A

repeat a set number of statements a fixed number of times

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

condition controlled time

A

repeat a set number of statements until a condition is met

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

Variable

A

a name refer to a particular memory location that is used to store data. The value of the data held in that memory location is not known when the program is written and can change while the program is running

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

constant

A

name used to refer to a fixed value. The value is set when the code is written and cannot change while the program is running

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

procedure

A

a self-contained set of commands that can be called from different parts of the program. returns 0 or many values.

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

function

A

a sub-routine that make take one or more parameters and ALWAYS returns a value

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

uses of functions and procedures

A

breaking a problem into manageable sections

preventing duplicating sections of code when it is needed more than once in a program

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

why is manageable code important

A

easy to read, debug and easy to maintain

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

\

A

integer division

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

AND

A

if both inputs are true the output is true else the output is false

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

OR

A

if both inputs are true or one input is true the the output is true else the output is false

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

NOT

A

reverses the outcome of the expression

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

assignment operator

A

single equals, sets the value on the right equal to the value on the left

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

procedural language

A

programming languages where the user gives step by step instructions of what to do

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

assembly language

A

a low level language represented by mnenomics which represents the machine code. one-to-one relationship with machine code.

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

programming paradigm

A

a way to classify programming languages based on their features.

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

3 programming paradigms

A

`procedural
Object Orientated
Assembly

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

why can assembly code for one processor not work for another processor

A

each type of processor has its own unique instruction set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Load instruction
LDA
26
store instruction
STA
27
input instruction
INP
28
Output instruction
OUT
29
end instruction
HLT
30
data storage instruction
DAT
31
add instruction
ADD
32
subtract instruction
SUB
33
branch always instruction
BRA
34
branch if zero or positive instruction
BRP
35
branch if zero instruction
BRZ
36
procedural language examples
Pascal, C, Basic and Python
37
Object Orientated languages examples
C++ and Java
38
Object Orientated language
coders develop a solution which consists of objects that have been modelled on the real world.
39
Class
a template to set out a define what attributes an object of a certain type should have
40
three main class sections:
class name attributes methods
41
instantiation
the process of creating an object from a class template
42
constructor method
signified by the key word new, initiated instantiation
43
inheritance
when a class takes on the methods and attributes of a parent class. The inheriting class may override or add new methods/attributes.
44
Superclass
the original class and its code
45
Subclass
the new class which inherited from the superclass
46
Over-riding
when the method in the subclass shares the same method as further up in the object tree. the over-ridden method takes precedence and replaces the method further up the object tree
47
Encapsulation
the protection of attributes and methods of an object so that they can't be accessed or altered by other objects. (keyword - private)
48
polymorphism
when something appears in multiple forms and the program makes sure the correct meaning of a function is run
49
assembly -> machine relationship
one-to-one
50
high level -> machine relationship
many-to-one
51
four ways of addressing memory in a computer
immediate direct indirect indexed
52
immediate addressing
when the value in the operand is the actual value to be used. this means the memory does not need to be searched
53
direct addressing
where the operand contains the address of the value to be used.
54
indirect addressing
where the operand contains the address which contains the address where the value can be found. useful because it means that the larger addresses in memory can be used to store
55
indexed addressing
The value given is added to the valued stored in the index register to give the memory location.
56
Benefits of assembly code (over high level)
- efficient as the code is more specifc - direct control of hardware - good if no compilers/interpreters installed - good if limited memory
57
Benefits of high level code (over assembly)
- optimisers may make code more efficient - intuitive and easier to write - can be recompiled for different architechtures - less code is written (shorter programs)
58
for loop pseudocode
for i=0 to 7 print(“Hello”) next i
59
while loop pesudocode
while condition= code endwhile
60
do until loop pseudocode
do code until condition
61
MOD
gives the remainder of a division
62
DIV
integer division (rounds down)
63
if/else Pseudocode
``` if condition then code elseif condition then code else code endif ```
64
switch/case pseudocode
``` switch condition: case “A”: code case “B”: code default: code endswitch ```
65
get the substring
stringname.subString(startingPosition, numberOfCharacters)
66
by default how are parameters passed?
by value
67
reading from a file
myFile = openRead(“sample.txt”) x = myFile.readLine() myFile.close()
68
writing to a file
myFile = openWrite(“sample.txt”) myFile.writeLine(“Hello World”) myFile.close()
69
procedure OO pseudocode
public procedure code endprocedure
70
Inheritance OO pseudocode
``` class Dog inherits Pet code endclass ```
71
create an instance of a class OO
objectName = new className(parameters)
72
Attribute
variables contained within and associated to an object
73
Method
a subroutine associated with an object
74
Object
Instance of a class
75
Characteristics of Procedural
instructions, sequences, selections, interaction, procedures and functions
76
Advantages of Using encapsulation
- reduces chance of error - consistent changes - prevents accidental changes
77
using a two dimensional array
[1,3] the first number is the column the second number is the row this would extract the number in the 1st column and the 3rd row
78
//
comment
79
.length()
find the length of the variable in front of the dot
80
auto-complete
feature of an IDE | can view identifiers and help avoid spelling mistakes/ typos
81
syntax highlighting
feature of an IDE | identify features quickly, makes it easier to check code is correct
82
stepping
feature of an IDE | run one line at a time and check result
83
breakpoints
feature of an IDE | stop the code at a set point to check the value of variables
84
variable watch window
feature of an IDE | checks values of variables and how they change during execution
85
error diagnostics
feature of an IDE | locate and report errors
86
why would something be passed by reference and not by value
- changes the value in the variable passed - passes the address/location - the change won't be lost when the procedure ends
87
write a constructor method
PUBLIC PROCEDURE NEW(parameters) SET ATTRIBUTES END PROCEDURE *done inside the class your making an instance of*
88
create an instance of a class
variable = new class(values for attributes)
89
passing by value
sends the actual data, if changes are made only the local copy is amended
90
passing by reference
send the address/location of the variables, if a change is made the original is also changed.
91
benefits of passing by reference
- existing memory space is used, no extra memory is required | - removes inconsistencies when passing to other procedures
92
benefits of passing by value
- doesn't change the original variable | - good if you don't want the original variable by edited
93
decomposition
splits problems into sub problems, splits these problems further until each problem can be solved
94
advantages of decomposition
- increase speed of development - assign areas to specialatieis - re-use modules
95
disadvantages of decomposition
- need to ensure sub programs interact correctly | - can introduce errors
96
advanatages of abstraction
- reduces processing/memory requirements | - increases response speed of programs
97
caching
data that has been used is stored in cache in case it is needed again allows for faster access for future use
98
benefits of concurrent processing
- saves time so long as processes are independent
99
drawbacks of concurrent processing
- tricky to test - tricky to code - won't neccessarily be twice as fast - takes up more memory
100
parallel computing
When more than one processor is executing separate instructions at the same time
101
concurrent processing
When more than one process is running from a program at once with each process in turn being given a slice of processor time/ running on a separate core
102
Default setting of methods and attributes
public
103
calling a method
object.method(parameters)
104
calling a superclass method
super.methodName(parameters) | for constructor: super.New()
105
Inheritance pseudocode
Class dog inherits pet set attributes methods endclass
106
Uses of superclass methods
``` subclass methods override the superclass method to support the greater specialisation defined by the subclass. It can be useful to call the superclass version before executing the specialised subclass method. ```
107
Calling the superclass method from an inherited class
public procedure new(parameters for class) super.new(name) set attributes end procedure