IAT 167 Lecture Notes - Lecture 4: Reference Type

54 views4 pages

For unlimited access to Class Notes, a Class+ subscription is required.

Week 4
Class, Object and ArrayList
Class
Class: definition for a certain type of object
Object: instance of the class with values filled into the template
Reference type variables: variables for demoting objects
E.g. class class_name {
number variables: holds its properties/states
methods: what it can do
}
1. Fields
Number variables used to store data in objects
E.g. int xPos; [store x-position]
1. Methods
E.g. class Bicycle {
void drawMe() {
}
}
1. Constructors
Type of method that set up the object by initializing its values
Has the same name as the class
No return type or void
E.g. constructor with no parameter:
class Bicycle {
int xPos;
int yPos;
int xSpeed;
Bicycle() {
xPos = 0;
yPos = height/2;
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
1 Booster Class