COMP 202 Lecture Notes - Lecture 8: Return Statement

11 views2 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

Printing and returning are not the same thing! A method returns something when the method call evaluates to a value that can be used in an expression. When a method prints something, it just displays text for the user to read. The method call does not evaluate to a value that can be used in an expression. When you have 2 methods in one class, to make your second method work, you need to call it in the main method to make it do something. See example code on mycourses that creates a method that takes no input and returns nothing, just prints. When a program runs, by default only the main method executes. Other methods only execute if they are called from the main method (or from a method that was called by the main method). Generally, inside of a method, all statements are executed from top to bottom. Methods can be called within other methods.

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