1. Fundamentals of Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a Data Type?

A

A Data Type describes how binary data of a Variable is used to represent a value. Examples of Data Types are: Integer (whole number), Float (real number), String (text), Boolean (true or false).

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

What is a Constant?

A

A Constant identifies a fixed value in memory.

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

What is a Variable?

A

A Variable identifies a value in memory which may change during the execution of the program.

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

What is Assignment?

A

Assignment is when a value is given to a Variable.

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

What do Sequence, Selection and Iteration refer to?

A

Sequence - code is executed line by line from the top of the program to the end.
Selection - a choice is made between different possibilities, for example with an IF-statement.
Iteration - code is repeated using a loop structure, for example a FOR or WHILE loop.

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

What is an Exception, and when do we use Exception Handling?

A

An Exception is an exceptional condition that arises during a program. An example would be an error caused by attempting to open a file which does not exist. Exception Handling is writing code to gracefully deal with the Exception which has occurred.

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

What is a Subroutine?

A

A Subroutine is a named block of code which can be called to perform a task.

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

What is a Function?

A

A Function is a Subroutine which returns a value when called.

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

What is a Parameter?

A

Parameters are Local Variables which hold the input values to a Subroutine. The values input into a Parameter are called Arguments.

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

What is the difference between Local and Global Variables?

A

Local Variables have a lifetime which is constrained by the scope of their enclosing subroutine. Global Variables exist throughout the entire program.

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

What is Concatenation?

A

Concatenation is when two Strings are combined together to create a new longer String.

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

What is a Module?

A

A Module is a grouping of related code into an independent unit, such as a file or library. It is often good practice to break complex programs into a series of Modules. These may also aid code re-use.

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

Explain the use of a Call Stack in executing Subroutines.

A

The Call Stack is used for memory allocation when a Subroutine is called. A Subroutine requires the following data: Parameters, Local Variables, and the return address. This data is allocated as a Stack Frame on the Call Stack. Every time a Subroutine is called it is allocating memory, and Subroutines calling other Subroutines build up the size of the Call Stack. If the Call Stack gets too big there will be a Stack Overflow which will crash the program, this is particularly an issue with Recursive Subroutines.

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

What is Recursion, and what is its purpose?

A

Recursion is when a Subroutine calls itself. Recursion allows the repetition of code without using Iteration (Loops). Recursion can lead to more elegant Algorithms than Iteration, but if the Recursion goes too deep it will cause a Stack Overflow of the Call Stack.

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

What is Procedural Programming?

A

Programs consists of Subroutines which call each other to solve a problem.

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

What is Object Oriented Programming?

A

Object Oriented Programming is where programs consist of Objects/Instances of Classes which interact with each other to implement behaviour.

17
Q

What is a Class?

A

A Class is a template for Objects/Instances. A Class may have Attributes (Variables attached to the Object) which represent its state and Methods (Subroutines/Functions attached to the Object) which represent its behaviour. Each Object maintains its own independent state which can change during the program by calling its Methods.

18
Q

What is Encapsulation?

A

Encapsulation is where an Object contains both its state (Attributes) and behaviours (Methods) together to represent some entity in the program. Each Object is independent of all other Objects, even if they are Instances of the same Class.

19
Q

What is Information Hiding?

A

Information Hiding is the use of Access Privileges to identify which Members (Attributes and Methods) of an Object can be interacted with by other Objects in the program. Public means that a Member can be accessed by any other Object. Private means it can only be accessed by other Instances of the same Class.

20
Q

What is Inheritance?

A

Inheritance is an “is-a” relationship between Classes (and Objects of those Classes). If a Dog Class inherits from a Mammal Class, then a Dog “is-a” Mammal, and has all the Members of the Mammal Class in addition to its own Members. Inheritance is a Parent Child relationship between Classes.

21
Q

What is an Association? What types of Association exist and how do they differ?

A

An Association is when an Object of one class contains Objects of another Class as its Attributes. It is an ownership relationship. There are two types of Association:

Aggregation - when the lifetime of the contained Object is independent of the Container Object.
Composition - when the lifetime of the contained Object is the same as the Container Object (i.e. it cannot exist independently).

22
Q

What is Polymorphism?

A

An Object of a Class has the identity of that Class and any other Classes above it in the same inheritance hierarchy. This is called Polymorphism. For example, if a Dog Class inherits from a Mammal Class which also inherits from an Animal Class - then a Dog Object “is-a” Dog and a Mammal and an Animal. Anything that can be done to an Animal Object can also be done to a Dog Object, and likewise with a Mammal Object.