Exam prep Flashcards

1
Q

What is a bit?

A

Smallest bit of information. It’s a zero or a one.

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

What is a byte?

A

8 bits. Those 8 bits are contiguous

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

What is a word?

A

A set of bits. most common being 8, 16, 32 and 64. You can pass a word to the cpu for processing.

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

What is fragmentation?

A

Storage space used in an inefficient way

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

What is a bus error?

A

When the memory is accessed by words but stored as bytes.

when your processor cannot even attempt the memory access requested

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

What is main memory?

A

This is your random access memory. Very fast memory that the cpu uses to temporarily store data.

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

What is secondary memory?

A

This is your HDD or SSD. Long term storage. A little slow. Keeps information even after computer is switched off.

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

What are I/O units

A

Peripherals used by humans to interact with the computer. Ie keyboard, mouse ect

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

What is cached memory?

A

memory that is stored on the cpu chip or very close by on the motherboard. Very fast.

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

What is a stack overflow? What may cause it?

A

A stack overflow is a run-time software bug when a program attempts to use more space than is available on the run-time stack

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

What is the order hierarchy of software?

A

from bottom to top : Code, Data, Heap, Stack.

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

(Hierarchy) What is code?

A

Where the compiled code resides. Usually read only.

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

(Hierarchy) What is Data?

A

Where variables that are accessible to everything (ie global variables) reside.

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

(Hierarchy) What is the stack? which way does it grow ?

A

The stack grows down. When we run our programs, the grow down on the stack.

. The stack is an area that typically has a predetermined size
. An example of allocating a variable to the stack would be : int a = 5;

stores temporary variables created by a function. In stack, variables are declared, stored and initialized during runtime.

Stores activation records

It is a temporary storage memory. When the computing task is complete, the memory of the variable will be automatically erased. The stack section mostly contains methods, local variable, and reference variables.

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

(Hierarchy) What is the heap? Which way does it grow?

A

The heap grows up. When we dynamically allocate data this will grow up in the heap.

. The heap is also predetermined but can grow.
. the new keyword is used to allocate something to the heap.

int *hval = new int; This is dynamically allocating a pointer onto the heap that points to a
int.
*hval = 5; To give it a value you need to dereference the pointer.

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

how many bytes is an int?

A

4 bytes

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

Declare an int variable a on the stack equal to 5.

A

int a = 5;

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

declare an int variable b on the heap qual to 5.

A

int* b = new int;

*b = 5;

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

Declare a int array on the stack of size 5

A

int a[5];

20
Q

Declare a int array on the heap of size 5

A

int *b = new int[5];

21
Q

Vector3 is a structure within the program. How would you initialise it to the stack?

A

Vector3 vector;

22
Q

Vector3 is a structure within the program. How would you initialise it to the heap?

A

Vector3* vector = new Vector3;

23
Q

If you have an int a = new int; and int b = new int[5] on the heap, how would you delete them

A

delete a;

delete[] b;

24
Q

Are the contents of a pointer checked at compile time or runtime?

A

The contents of the pointer are checked in runtime. This is due to the fact that you can’t store a constant in a pointer.

25
Q

Convert 163 into binary

A

10100011

26
Q

convert 100101110 into decimal

A

302

27
Q

What is 2’s complement? what is the most negative number that can be represented in one byte?

A

-127

28
Q

What is the difference between an object and methods?

A

A method is a function that an object is able to use.

29
Q

What is Inheritance?

A

The capability of a class to derive properties and characteristics from another class is called Inheritance

30
Q

What is encapsulation?

A

Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. … All variables or functions defined after the public specifier are accessible by all other functions in your program.

31
Q

What is polymorphism?

A

Polymorphism is the ability to create a property, a function or an object that has more than one realisation.

This is sometimes done by using the virtual keyword.

32
Q

What is slicing?

A

“Slicing” is where you assign an object of a derived class to an instance of a base class, thereby losing part of the information - some of it is “sliced” away.

For example,

class A {
   int foo;
};
class B : public A {
   int bar;
};
So an object of type B has two data members, foo and bar.

Then if you were to write this:

B b;

A a = b;
Then the information in b about member bar is lost in a.

33
Q

What is the memory hierarchical memory structure?

A

1) register memory
2) Cache memory
3) Main memory - ie ram
4) Secondary memory - ie ssd

34
Q

What are the five big O notation from least complex to most complex

A

1: O(1)
2: O(log n)
3: O(n)
4: O(n log n)
5: O(n*n)

35
Q

What is Coupling

Talk about loose coupling and high coupling

A

Coupling is the degree of dependance between two classes

Loose coupling means that the classes that are grouped have few interdependencies allowing you to change something without need to change a whole bunch of other code in connected classes

Tight or high coupling means that the classes have many interdependencies meaning that if you change something from one class, you’re going to have to change a lot of code that is connected to that class

36
Q

What is abstraction

A

methodology in which details of the programming codes are hidden away from the user, and only the essential things are displayed to the user.

37
Q

What is polymorphism

A

A oop concept that allows programmers to create functions and methods that can be implemented differently in child classes.

An example that we have used in this class is using the virtual keyword.

38
Q

What is cohesion

What is high cohesion?

What is low cohesion?

A

Cohesion refers to what the class (or module) can do. Low cohesion would mean that the class does a great variety of actions - it is broad, unfocused on what it should do. High cohesion means that the class is focused on what it should be doing, i.e. only methods relating to the intention of the class.

39
Q

What is method movement?

This applies to refactoring code.

A

Moving a method around in the class when refactoring code.

40
Q

What is a ‘has a’ relationship?

A

A has a relationship is a composition relationship.

ie, cart has meerkats

41
Q

What is a ‘is a’ relationship?

A

A is a relationship is an inheritance relationship.

ie, a piano is an instrument.

42
Q

What is the register’s memory used for?

A

Registers, on the other hand, are accessed as part of the machine’s computing instructions. When the machine processes “add x to y and store in z” it accesses registers*.

43
Q

What is the cache’s memory used for?

A

Caches live on the memory side of that. Loads and stores will treat cache just as they treat memory (only faster). Caches are addressed using memory addresses. And as far as the compute side knows, they’re accessing memory.

44
Q

Convert 126 into binary

A

1111110

45
Q

Convert 0xFE into decimal

A

-

46
Q

What is an objects state and behaviour?

A

state and behaviour are the basic properties of an Object.

state tells us about the type or the value of that object where as behaviour tells us about the operations or things that the object can perform.

For example let’s say we have an Object called car

so car object will have colour, engine type, wheels etc as it’s state,

this car object can run at 180kmph, it can turn right and left, it can go back and forth, it can carry 4 people etc. These are it’s behaviours.