Object descriptions

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Object descriptions

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which item is listed in an object description?
A The object name, its attributes with data types, and its methods
B Only the final output shown on screen
2. Which attribute entry is written correctly in an object description?
A studentName - print()
B studentName - String
3. What does the methods section of an object description show?
A The data type of every attribute
B What each method does and the parameters it needs
4. Which is a sensible object name for an object description?
A Student
B calculateTotalMark()
5. Which method row is complete in an object description?
A setMark(newMark) - changes the student's mark to a new value
B setMark - Integer

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Object name: Student AThe attributes have no data types listed. Each attribute needs a type, such as studentName (String) and yearLevel (Integer).
2Methods: calculateAverage(marks) - returns the mean mark BAttributes: studentName (String), yearLevel (Integer)
3Each attribute in an object description is listed with its name and its data type. CThe methods section is missing. The description should list methods such as getTitle() with their parameters and purpose.
4An object description differs from a data dictionary because it also lists the methods the object can perform. DNames the class or object being described, such as Student, at the top of the object description.
5Object name: Student Attributes: studentName, yearLevel ELists a behaviour of the object with its parameters and a short statement of what it does.
6Object name: Book Attributes: title (String), pages (Integer) Methods: (none listed) FMethods: setYearLevel(newLevel) - changes the year level

Definitions

object description

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
___________: Student Attribute: studentName (String)
2.
Object name: Product Attribute: price (_____)
3.
Object name: Book Attribute: isBorrowed (_______)
4.
Object name: Student Method: addPoints(______) Purpose: adds to the points attribute
5.
Object name: Account Attribute: balance (Float) ______: deposit(amount)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Object: Book
B Attribute: title (String)
C Attribute: pages (Boolean)
D Method: getTitle() -> String
Question 2
A Object: Student
B Attribute: name (String)
C Attribute: mark (Float)
D Method: getMark() -> Boolean
Question 3
A Object: speed (Integer)
B Attribute: speed (Integer)
C Method: accelerate(amount)
Question 4
A Object: Pet
B Attribute: age
C Attribute: name (String)
D Method: feed() - adds food
Question 5
A Object: Account
B Attribute: deposit(amount)
C Method: withdraw(amount)
D Method: getBalance() -> Float

Answer Key

Object descriptions
Section A: Quick Questions
Q1
A — The object name, its attributes with data types, and its methods
Q2
B — studentName - String
Q3
B — What each method does and the parameters it needs
Q4
A — Student
Q5
A — setMark(newMark) - changes the student's mark to a new value
Section B: Match the Pairs
Q1
Object name: Student → Names the class or object being described, such as Student, at the top of the object description.
Q2
Methods: calculateAverage(marks) - returns the mean mark → Lists a behaviour of the object with its parameters and a short statement of what it does.
Q3
Each attribute in an object description is listed with its name and its data type. → Attributes: studentName (String), yearLevel (Integer)
Q4
An object description differs from a data dictionary because it also lists the methods the object can perform. → Methods: setYearLevel(newLevel) - changes the year level
Q5
Object name: Student Attributes: studentName, yearLevel → The attributes have no data types listed. Each attribute needs a type, such as studentName (String) and yearLevel (Integer).
Q6
Object name: Book Attributes: title (String), pages (Integer) Methods: (none listed) → The methods section is missing. The description should list methods such as getTitle() with their parameters and purpose.
Section C: Definitions
Q1
object description — A design table for a class that lists its name, its attributes with data types, and its methods with their parameters and purpose.
Section D: Fill in the Blanks
Q1
Object name: Student Attribute: studentName (String)
Q2
Object name: Product Attribute: price (Float)
Q3
Object name: Book Attribute: isBorrowed (Boolean)
Q4
Object name: Student Method: addPoints(points) Purpose: adds to the points attribute
Q5
Object name: Account Attribute: balance (Float) Method: deposit(amount)
Section E: Spot the Error
Q1
C — A page count is a whole number, so the attribute's data type should be Integer, not Boolean.
Q2
D — getMark() returns the mark attribute, which is a Float, so the method must return Float, not Boolean.
Q3
A — The first line of an object description gives the object's name (Car). Attributes and their data types come on later lines.
Q4
B — Every attribute in an object description needs a data type. It should be Attribute: age (Integer).
Q5
B — deposit(amount) is an action that takes a parameter, so it is a method. Attributes store data and have a data type, so this line should start with Method:.