Free Online Flashcard Deck

Java Methods and Program Design Free Online FlashCards

Study Java Methods and Program Design with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a Java method?

Back

A method is a named block of Java code that runs when it is called. It supports procedural abstraction by hiding implementation details behind a usable operation.

02
Front

What are the main parts of a method declaration?

Back

A method declaration commonly includes an access modifier, return type, name, parameter list, and body.

03
Front

What does void mean as a method return type?

Back

A void method performs an action but produces no value, so its call cannot be used in an expression or assigned to a variable.

04
Front

How do parameters differ from arguments?

Back

A parameter is a variable declared in a method header; an argument is the value supplied for that parameter when the method is called.

05
Front

What happens when a primitive argument is changed inside a method?

Back

Java passes primitive arguments by value, so the method receives a copy. Changing its parameter does not change the caller’s original variable.

06
Front

What can a method do with a reference-type argument?

Back

Java passes a copy of the reference. The method can change the shared object’s contents, but assigning a new object to the parameter does not change the caller’s reference.

07
Front

What does return do in a non-void method?

Back

A return statement ends the current method and sends a value to the caller. Every possible path of a non-void method must return a compatible value.

08
Front

What constitutes a Java method signature?

Back

A method’s signature consists of its name and ordered list of parameter types. Its return type is not part of the signature.

09
Front

What is method overloading?

Back

Overloading means defining methods with the same name but different parameter lists. Java selects the applicable overload using the number and types of arguments, not the return type.

10
Front

What determines the scope of parameters and local variables?

Back

A parameter’s scope is the entire body of its method. A local variable’s scope extends from its declaration to the end of its enclosing block.

11
Front

How does this resolve a field–parameter name conflict?

Back

When a parameter has the same name as a field, the parameter takes precedence in the method. this.name refers specifically to the current object’s field.

12
Front

What is the difference between a precondition and a postcondition?

Back

A precondition must be true before a method runs; a postcondition must be true after it finishes. Together they form a contract between caller and method.