Paper 2 , cram here Flashcards

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

What is Recursion? (2 points)

A

A function that calls itself
Has a base case / stopping condition
where it won’t call itself.

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

What are some advantages and disadvantages of Recursion?

A

+ Easier to understand (sometimes)
+ Fewer lines of code

  • Can cause stack overflow errors
  • Less time efficient
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Iteration?

A

Repeating the same code more than
once

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

What are some advantages and disadvantages of Iteration?

A

+ Takes up less space
+ More time efficient

  • Harder to understand (sometimes)
  • More lines of code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Local Variables?

A

Variables only accessible in the
subroutine or structure they are
defined in.

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

What are some advantages and disadvantages of Local Variables?

A

+ Take up less memory
+ Can reuse names
+ Can’t be accidentally changed

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

What are Global Variables?

A

Variables accessible from anywhere in
the program.

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

What are some advantages and disadvantages of Global Variables?

A

+ Bigger scope
- Take up more memory
- Can’t reuse names
- Can be accidentally changed

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

What are Parameters by Value? (2 points)

A

A copy of the value of the variable is
given as a parameter.

Won’t change the value outside of the
subroutine.

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

What are Parameters by Reference? (2 points)

A

A pointer to the location of the variable is given as a parameter.

Will change the value outside of the subroutine.

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

What is Encapsulation?

A

Hiding data so it can’t be accessed outside of an object

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

What is Inheritance?

A

A child class taking all the attributes and methods of a parent class

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

What is Polymorphism?

A

When methods with the same name in a parent and child class do different things

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