Week 2 Flashcards

1
Q

What does it mean for a method to be public?

A

This means it can be invoked (or “called”) from other classes.

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

What does it mean for a method to be void?

A

This means that they don’t return a result.

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

Why write methods?

A
  1. Creating a new method allows you to name a block of statements, which makes the code easier to read and understand.
  2. Introducing new methods can make the program shorter by eliminating repetitive code.
  3. Methods allow you to focus on each subproblem in isolation and then compose them into a complete solution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the Flow of Execution? Not the definition, but the order.

A

Programs always begin at the first statement of main, regardless of where it is in the source file. Statements are executed one at a time, in order, until you reach a method invocation, which you can think of as a detour. Instead of going to the next statement, you jump to the first line of the invoked method, execute all the statements there, and then come back and pick up exactly where you left off.

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

What are Parameters?

A

Parameters, are the values you provide in parentheses when you invoke the method, and are variables that indicate what arguments are required.

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