Methods
Syntax
Common Errors
Loops
Methods pt.2
100

The method header is followed by the _______

Method Body

100
How do you write a while loop?

while(condition)

example: while (int < 0 && int > 10)

100

What is a good way to debug if you do not know what is wrong?

adding print statements to check the values of your variables! will accept other answers as well
100

When do you use a for loop?

When you know how many times you want it to run

100

How do you call a method on it's own? (not assigning a variable) 


methodName(any parameters)

200

A method has a return expression and returns type. What is important about their relationship?

They MUST match


200

How do you write a for loop?

for(int i = x; i < y; i(++/--)){

}

200

What does this error mean?
error ";" expected

You forgot a semicolon

200

When do you use a while loop?

When you don't know how many times you want it to run.

200

How do you call a method on a variable?

variable.methodName(any parameters)

300

What is included in the method signature?

Method name and parameter list

300

How do you write a for loop where the incrementor counts DOWN?

for (int i = x, i < y; i--){

}

300

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

300

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.

300

Do methods need parameters?

No

400

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

400

What is used to print something out? 

System.out.println("whatever you want")

400

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.

400

How do you increment the incrementor for addition or subtraction?

i++

i--

400

What is the return type of a method that uses system.out.print?

void

500

What is the scope of a variable created within a method?

Only accessible within the method

500

How do you print out a message that includes a base message and a changing variable?

Systetem.out.println("base message" + variable);

500

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"

500

What causes an infinite loop?

When the condition to end the loop can never occur

500

Bonus +100 to the team who chose this box and gets it right! Why are methods important?
hint...what do they increase?

Code reusability!

M
e
n
u