The method header is followed by the _______
Method Body
while(condition)
example: while (int < 0 && int > 10)
What is a good way to debug if you do not know what is wrong?
When do you use a for loop?
When you know how many times you want it to run
How do you call a method on it's own? (not assigning a variable)
methodName(any parameters)
A method has a return expression and returns type. What is important about their relationship?
How do you write a for loop?
for(int i = x; i < y; i(++/--)){
}
What does this error mean?
error ";" expected
You forgot a semicolon
When do you use a while loop?
When you don't know how many times you want it to run.
How do you call a method on a variable?
variable.methodName(any parameters)
What is included in the method signature?
Method name and parameter list
How do you write a for loop where the incrementor counts DOWN?
for (int i = x, i < y; i--){
}
What could the error
"cannot find symbol" mean?
You forgot to import/declare something, you have the wrong name for a method call, forgot to make a scanner... essentially means computer does not know what you are saying
When do you use a do-while loop?
When you do not know how many times you want the loop to run, but you know you want it to run at least once.
Do methods need parameters?
No
What is the difference between actual parameters and formal parameters?
Actual parameters: the values you pass in and the method operates with
Formal parameters: the name/s the method will use to operate on the passed in values
What is used to print something out?
System.out.println("whatever you want")
If you get an error that says "out of bounds", what do you look for?
Trying to access an index of something that does not exist.
How do you increment the incrementor for addition or subtraction?
i++
i--
What is the return type of a method that uses system.out.print?
void
What is the scope of a variable created within a method?
Only accessible within the method
How do you print out a message that includes a base message and a changing variable?
Systetem.out.println("base message" + variable);
What is the difference between declaring and initializing a variable?
Declare: int num
Initialize: num = 0
Declaring says, "I am making a variable, and this is it's data type" While initializing says "I have this variable and I want to give it this value"
What causes an infinite loop?
When the condition to end the loop can never occur
Bonus +100 to the team who chose this box and gets it right! Why are methods important?
hint...what do they increase?
Code reusability!