CS 151 Lecture 9: Sections 4.4-4.5

108 views3 pages

Document Summary

Method declaration specifies the code that is executed when a method is invoked. When a method is called, the flow of control transfers to that method. If the called/invoked method is part of the same class, only the method name is needed to invoke it. If it is part of a different class, it is invoked through the name of an object of that other class. The header of a method includes the type of the return value, the method name, and a list of parameters that the method accepts. A method is defined by optional modifiers, followed by a return type, followed by an. Identifier that determines the method name, followed by a list of parameters, followed by the method body. The return type indicates the type of value that will be returned by the method, which may be void. The method body is a block of statements that executes when the method is invoked.

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

Related Questions