4.1 Fundamentals of Programming Flashcards
Cover all of topic 4.1
What is the difference between a variable and a constant?
A variable has a value that can be changed during execution, a constant’s value stays the same.
What are advantages of using named constants in programming?
Avoid repetition of important values.
Easier to remember the constant name than its value.
What is a subroutine?
A named ‘out of line’ block of code that may be executed by writing its name in the program
What are advantages of using subroutines in programs?
Decomposes the program into several parts making it easier to solve problems.
Easier to debug.
Easier to understand the code.
What is the scope of a local variable?
Within its subroutine.
When does a local variable exist?
Only when the subroutine it is in is running.
Why is it good practise to use local variables (instead of global ones)
Local variables only take up memory space whilst their subroutine is run.
Describe a class
Something that defines methods and properties which capture the behaviour and common characteristics of objects.