Paper 2 , cram here Flashcards
What is Recursion? (2 points)
A function that calls itself
Has a base case / stopping condition
where it won’t call itself.
What are some advantages and disadvantages of Recursion?
+ Easier to understand (sometimes)
+ Fewer lines of code
- Can cause stack overflow errors
- Less time efficient
What is Iteration?
Repeating the same code more than
once
What are some advantages and disadvantages of Iteration?
+ Takes up less space
+ More time efficient
- Harder to understand (sometimes)
- More lines of code
What are Local Variables?
Variables only accessible in the
subroutine or structure they are
defined in.
What are some advantages and disadvantages of Local Variables?
+ Take up less memory
+ Can reuse names
+ Can’t be accidentally changed
- Smaller scope
What are Global Variables?
Variables accessible from anywhere in
the program.
What are some advantages and disadvantages of Global Variables?
+ Bigger scope
- Take up more memory
- Can’t reuse names
- Can be accidentally changed
What are Parameters by Value? (2 points)
A copy of the value of the variable is
given as a parameter.
Won’t change the value outside of the
subroutine.
What are Parameters by Reference? (2 points)
A pointer to the location of the variable is given as a parameter.
Will change the value outside of the subroutine.
What is Encapsulation?
Hiding data so it can’t be accessed outside of an object
What is Inheritance?
A child class taking all the attributes and methods of a parent class
What is Polymorphism?
When methods with the same name in a parent and child class do different things