Methods Flashcards

1
Q

required elements of a method declaration

A

methods return type, name, pair of parenthesis and a body between braces

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

what is a methods signature

A

method name and parameter types

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

visibility of a method

A

Determines whether a method is available to other classes
public - allows any class to access the method
private - hides method from other classes
protected - lets subclasses use the method but hides the method from other classes outside the package

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

what is a static method

A

(opposed to instance method) it means you can call the method without first creating an instance of the class in which its defined (like when you create a scanner)

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

declaration in action

A

visibility/returntype/methodname/parameterlist{
statement
}

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

main method

A

calls all other methods required to run your application

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

invoking the method

A

when you write up the mthod in main, you are invoking it

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

getting the current year

A

import java.util.Calendar
int current year =
Calendar.getInstance().get(java.util.Calendar.YEAR);

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

delay method

A

– Adds a delay between output of program
private static void delay() {
try{
Thread.sleep(millisecs);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

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

what is passing a parameter into a method called

A

parameter passing

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