AP Computer Science A · Lesson 3.5 · Unit 3 · CED topic 3.5

Methods: void, non-void, and return

Name:   Date:  

1 Why this lesson matters

Read the opening paragraph and the "Required content" box on the lesson page. In your own words, explain each objective below.

5.A. Develop code to define behaviors of an object through methods written in a class using primitive values and determine the result of calling these methods.

2 Void and non-void methods

Read this section. In your own words, summarize the main idea.

3 The return statement

Read this section. In your own words, summarize the main idea.

4 Worked example

Read the "Worked example" box. Then, without looking back, try writing your own answer below.

Write a method that returns the smallest divisor of n that is greater than 1.

5 Exam focus: avoid this mistake

Read the "Exam focus" box, then restate it in your own words.

6 Sum it up

In two or three sentences, explain this lesson's main idea to someone who has not read it.