COP 3502 Chapter Notes - Chapter 6: Local Variable, Information Hiding, Type Signature

48 views2 pages

Document Summary

Methods can be used to define reusable code and organize and simplifying coding. Method: a collection of statements grouped together to perform an operation. A method definition consists of its method name, parameters, return value type, and body. Actual parameter (i. e. , argument ): the value passed to the parameter. Formal parameter (i. e. , parameter): the variable defined in the method header. Method signature: the method name and the parameter list (method"s type, order, and number of the parameters) together. Modifier: the static modifier is used for all the methods in this chapter. Calling a method executes the code in the method. Listing6. 1 testmax. java: shows a complete program that is used to test the max method. A void method does not return a value. Listing 6. 2 testvoidmethod. java: gives a program that defines a method named printgrade and invokes it to print the grade for a given score.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents