4.1 Fundamentals Of Programming Flashcards

1
Q

What are pointers

A

Variables that are used as stores for memory addresses if objects created at runtime

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

What is a procedure and what are the advantages

A

A procedure is a section of a computer program that can be used when required at several different points in the program

It can help save time, keep code easy to maintain and to ensure bugs can be found easily

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

Difference between local and global variables

A

The main difference between a local and global variable is that a local variable is declared inside a function or other
enclosed code block. In contrast, the global variable is declared outside the functions in the program.

A global variable can be used throughout the computer program, where a local variable can only be used within the
enclosed code block where it is declared. As soon as the enclosed code block finishes executing, the variable falls out
of scope and the memory is freed up for other uses (it will no longer exist).

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

Role of stack frames

A

Every time a subroutine calls another subroutine or function, the state of the stack for the calling sub routine needs
to be remembered. This is achieved by using a stack frame.
As the computer encounters a function or subroutine call, it
stores the local variables, parameters and current address in
memory and adds it to the stack. Once it is done with the call,
it removes that frame from the stack and looks at the return
address of the next frame (which would belong to the
function that called it) and resumes executing at that point.
This goes on until the stack is empty (i.e., it returns to the first
subroutine in the program) and the program finishes.

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

What is recursion/ a recursive algorithm

A

Recursion is to define a problem (or function/subroutine) in terms of itself.

The term re-entrant is used to describe a recursive call. The base case is the condition in which the recursive calls
will begin to unwind. The general case is the condition in which a recursive call will be made.

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

Advantages of structured programming

A
  • Easier to read and understand
  • User Friendly
  • Easier to Maintain
  • Mainly problem based instead of being machine based
  • Easier to Debug
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define Class

A

A class defines methods and property/attribute fields that capture the common behaviours
and characteristics of objects. A class is a template that can be used to create objects.

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

Define Object

A

An instance of a class.

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

Define Behaviours/Methods

A

The procedures of an object – what the object does

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

Define Attributes/Properties

A

A characteristic of an object

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

Define Instantiation

A

The definition (creation) of an object based on a class.

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

Define Encapsulation

A

A technique used to hide data (data hiding) allowing only certain data to be protected (or not)
from modification outside of the class. This is done using the private, public, protected
modifiers.
Public (+) Encapsulation - Can be accessed by any other code outside of the class it was declared within.
Private (-) Encapsulation – Can only be accessed within the same class.
Protected (#) Encapsulation – Can only be accessed within the same class and inherited classes.

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

Define Inheritance

A

The relationship between two objects in which one is a kind of the other and shares some of its properties and methods.

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

Define Aggregation

A

Aggregation means using instances of classes in other classes. These instances should not be

destroyed when the class using them is destroyed.
In the Unified Modelling Language (UML) aggregation is represented by a white diamond line.

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

Define Composition

A

Composition means using instances of classes in other classes. These instances should be
destroyed when the class instantiating them is destroyed.
In the Unified Modelling Language (UML) composition is represented by a black diamond line.

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

Define Polymorphism

A

Allows inherited properties and methods to be overridden.

Poly=Many Morphism=Different

17
Q

Define Overriding

A

The process of over-riding a method which may have been inherited from a parent class.

18
Q

Abstract, Virtual & Static Methods

A
  • Abstract methods cannot be called directly and must be inherited in order to be used (implemented).
  • Virtual methods can be overridden by a method in a child class.
  • Static methods are class-level methods and are the same across all instances of a class (objects). The code in
    a static method cannot access object level variables, only static variables can be accessed.