Week 2 Flashcards
What does it mean for a method to be public?
This means it can be invoked (or “called”) from other classes.
What does it mean for a method to be void?
This means that they don’t return a result.
Why write methods?
- Creating a new method allows you to name a block of statements, which makes the code easier to read and understand.
- Introducing new methods can make the program shorter by eliminating repetitive code.
- Methods allow you to focus on each subproblem in isolation and then compose them into a complete solution.
What is the Flow of Execution? Not the definition, but the order.
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.
What are Parameters?
Parameters, are the values you provide in parentheses when you invoke the method, and are variables that indicate what arguments are required.