Topic 1: Fundamentals of programming Flashcards
What is inheritance?
Inheritance allows one class to share the properties and method of another class, while having its own properties and methods too
What are the names given to the class being inherited and the inheriting class?
The class being inherited from- Superclass
The class that is inheriting - Subclass
What is overriding?
An overriding method has the same name method as a method in an inherited class but different implementation
Integer
A whole number, positive or negative, including zero
Real/float
A positive or negative number which can have a fractional part
Boolean
A value which is either true or false
Character
A single number, letter or symbol
String
A collection of characters
Data/Time
A way of storing a point in time, many different formats are used
Pointer/ Reference
A way of storing memory addresses
Records
A collection of fields, each of which could have a different data type. You can think of a record as a row from a table
Arrays
A finite indexed set of related elements each of which has the same data type
Variable decleration
Creating a variable for the first time, giving it a name and sometimes a data type
Constant decleration
Creating a constant a constant for the first time, giving it a name and sometimes a data type(the value doesn’t change when the program is running)
Assignment
Giving a constant or variable a value
Iteration
Repeating an instruction, this could be definite or indefinite
Selection
Comparing values and choosing an action based on those values
Subroutine
A self contained set of commands that can be called from different parts of a program
Definite iteration
A type of iteration in which the number of repetitions required is known before the loop starts
Indefinite iteration
The number of repetitions is not known before the loop starts, the loop terminates when the conditions are met
Nested structures
This is when one structure is placed within another.
What is volatility
Data which is not stored permanently and will therefore be lost should the program crash
Parameters
These are used to pass data between subroutines within programs, (specified within brackets)
Argument
The actual value passed by a parameter
Function
A subroutine that always returns a value
Local variables
Declared and used inside a subroutine, only available to that routine. Created when routine is called and destroyed when it ends
Global variables
Declared at the top of a program outside of subroutines. Usable throughout the program, created when program starts and destroyed when it ends
Selection
Do a set of statements based on a condition
Iteration
Do a set of statements again and again
Definite itereation
Do a set of statements again and again a known number of times
Indefinite iteration
Do a statement again and again until a condition is met
Difference between a procedure or function
Both procedures and functions take parameters and carries out a set of tasks whilst a function returns a value
Identifier
a name used to identify an entity in a program
Variable
A name used to refer to
a particular memory location that is used to store data
Constant
A name used to refer to a fixed value
Advantages of constants over variable
-Cannot accidently change constant
-The program runs faster
-If value needs to be changed at a later date you just change it once
-Expressions using the value are much easier to understand if you choose an appropriate identifier
How do you generate a new random number in VB
Randomize()
Rnd()
Procedure
A self contained set of commands that can be called from different parts of the program
Function
A function is a sub-routine that may take one or more parameters and returns a value
Exception handling
As a programmer you should try to anticipate possible errors and write code to deal with them
How do you do exception handling in VB.net?
try
…
catch
….
end try
Recursion
A subroutine which calls itself
The key characteristics of recursive algorithms
(3 points)
Must contain a stopping condition(base case)
For any input values other than the stopping condition the routine must call itself
The stopping condition must be reachable after a finite number of times
Is recursion better than iteration?
No as recursion isn’t very efficient on memory