Using Methods Flashcards

1
Q

A sequence of operations that a computer program can execute on demand

A

Method

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

An executable statement that tells the computer to transfer execution to the method body

A

Method call

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

Datum that is passed to a method when it is called

A

Argument

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

Datum given back by a method when it returns from a call

A

Return value

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

What we call a method when it calls another

A

Caller

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

What is an executable statement that transfers execution to the method body?

A

Method call

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

What is a declaration that gives the information you need to use a method?

A

Method specification

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

What facts should be provided by a method specification?

A

A description of what it does, the data type of its return value, whether or not its static, the data type of each argument, and its identifier

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

Given the method specification below, which statement correctly calls the method?

double federalTax( double grossPay, int w4allowances )

A

double tax = federalTax( 1_300, 2 );

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

Given the method specification below, which statement correctly calls the method?

long currentTimeInMilliseconds( )

A

long time = currentTimeInMilliseconds( );

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

Given the method specification below, which statement correctly calls the method?

double mm( int inches)

A

double millimeters = mm( 2 );

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

Given the method specification below, which statement correctly calls the method?

void setTime( int hour, int minutes, char meridiem )

A

setTime( 5, 30, ‘A’ );

  • Don’t put the return value when calling the method if its void in the first place
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

double federalTax( double grossPay, int w4allowances )

Given the method specification above, which statement best describes the statement below?

federalTax( 1_300.00, 4 );

A

It correctly calls the method but loses its return value.

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

A method with the same identifier that has several declarations, each of which takes different arguments, is said to be __________.

A

Overloaded

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

Given this Spinner class, which Java statement correctly builds a Spinner object? (There are three)

public class Spinner {
     private int low, high, range;
     public int stoppedAt;
     public Spinner( int lo, int hi ) {
          low = lo; high = hi;
          range = (high - low) + 1;
          spin( ); }
     public Spinner ( int hi ) {
          this( 1, hi ); }
     public Spinner( ) {
          this( 10 ); }
     public void spin( ) {
          stoppedAt = (int) (Math.random( ) * range + low) ; 
}}
A
Spinner s = new Spinner( ); 
Spinner s = new Spinner( 54 ); 
Spinner s = new Spinner( 0, 37 );
How well did you know this?
1
Not at all
2
3
4
5
Perfectly