Chapter 6 Quiz

Ace your homework & exams now with Quizwiz!

A variable declared in a method is called a what?

A local variable

stub

A simple but incomplete version of a method can be used for the methods waiting to be implemented

pass-by-value

A value of an argument is passed to the parameter

Describe method abstraction

Achieved by separating the use of a method from its implementation. The client can use a method without knowing the program's implementation. Also known as information hiding or encapsulation

Method signature

Composed of the method name and the parameter list

method

Consists of its modifier, method name, parameters, return value type and body. May return a value, or returnValueType. Otherwise void.

overloading methods

Enables you to define the method with the same name as long as their signatures are different

scope of a variable

Part of the program where the variable can be referenced

Some programming languages refer to methods as __________ and __________. difference?

Procedures and functions; procedures are void methods and a value-returning method is called a function

Methods

Provide powerful constructs

Parameter's list

Refers to the type, order, and number of a method's parameters.

Describe the scope of a local variable

STARTS from its declaration and continues to the end of the block that contains the variable. Must be declared and initialized before it is used

divide and conquer

Stepwise refinement; decomposing a program into subproblems

method signature

The method name and the parameter list together

argument

The value passed to the parameter, or actual parameter

actual parameter

The value passed to the parameter, or argument. They are optional, like look at Math.random()

What does it mean for a method to be overloaded?

This means that two methods can have the same name, as long as their method parameter lists differ

What approaches are useful for large programs and why?

Top-down or bottom-up approach. Writing a program all at once is ill-advised, it takes repetitive compilations and systemic debugging, leading to saving time

formal parameter (i.e., parameter)

Variables defined in the method header

When a method is called and the program control goes to that method, when does this control return to the caller?

When the return statement is executed or its method-ending closing brace is reached

ambiguous invocation

When two or more possible matches for the invocation of a method are present, and the compiler cannot determine the best match.

Are parameters optional?

Yes, so a method doesn't need parameters

Can a value-returning method also be invoked as a statement in Java?

Yes; in this case, the caller simply ignores the return value

Can a return statement be used in a void method for terminating the method and returning to the method's caller?

Yes; this is useful occasionally for circumventing the normal flow of control in a method

modifier

like "public static"

Method header specifies ________________.

modifiers, return value type, method name, parameters

The arguments that are passed to a method should have the same _______, _______, and ______ as the parameters in the method signature

number, type, and order

A method may return a value. The (1) ___________ is the data type of the value the method returns. If no value is returned, the (1) _______ is the keyword (2)_________?

returnValueType; void


Related study sets

Maternity and Women's Health Nursing - Women's Health

View Set