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

Constructors

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.

4.A. Develop code to declare instance variables for the attributes to be initialized in the body of the constructors of a class.

2 State and the constructor

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

3 When you write no constructor

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

4 A constructor that receives an object

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

5 Worked example

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

Write a class Rectangle with a width and a height. One constructor takes both; another takes one side and makes a square.

6 Exam focus: avoid this mistake

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

7 Sum it up

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