Topic One - Programming Flashcards
Integer
Whole number, positive or negative
Real/Float
+/- that can have a fractional part
Boolean
True or False
Character
Single letter or symbol
String
Collection of characters
Pointer
A way of storing memory addresses
Record
A collection of fields each of which could have a different data type
Arrays
A finite, indexed set of related elements each of which has the same data type
What happens after an exception has been ‘thrown’?
Once an exception has been thrown, the computer has to handle the exception to avoid crashing. It does this by pausing execution of the program and saving the current volatile state of the program on the system stack before running a section of code called a catch block. This code will prevent the program from crashing and might inform the user that an error has occurred. Once the exception has been handled, the program uses the system stack to restore its previous state before resuming execution.
What is the difference between a function and a procedure?
A function must return a value whereas a procedure does not have too.
What is a Local variable?
A local variable is a variable that can only be accessed from the subroutine within which it is declared.
What is a global variable?
Global variables can be accessed from any part of a program and exist in memory for the entire duration of the program’s execution.
What is the role of stack frames in a subroutine?
Stack frames are used by computers to store return addresses, parameters, and local variables for each subroutine call that occurs during the execution of a program. If one subroutine calls another, nesting is said to occur. Each subroutine call will be pushed onto the computer’s call stack in the form of a stack frame before the subroutine’s code begins to execute. When the nested subroutine finishes executing, the stack frame is popped from the call stack and the computer uses the information to return to execution of the previous subroutine.
What is a recursive subroutine?
A recursive subroutine is one which is defined in terms of itself. This means that somewhere within the recursive subroutine, there is a call to the subroutine itself. Any recursive subroutine must meet have a stopping condition (called a base case) which must be met at some point in the execution of the program. If an algorithm calls itself, but doesn’t have a base case, it will never terminate. This will cause a stack overflow as more and more stack frames are pushed onto the call stack.