08ObjectsAndReference

08ObjectsAndReference - CSE 114 Computer Science I Objects...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Bryce Canyon, Utah CSE 114 – Computer Science I Objects and Reference
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Classes Class —definition of a kind of object Like an outline or plan for constructing specific objects Class specifies what kind of data objects of that class have Each object has the same data items but can have different values Class specifies what methods each object will have All objects of the same class have the same methods available to them
Background image of page 2
Class as an Outline Class Name: Automobile Data: amount of fuel ________ speed ________ license plate ________ Methods (actions): increaseSpeed: How: Press on gas pedal. stop: How: Press on brake pedal. Class Definition Objects that are instantiations of the class First Instantiation: Object name: patsCar amount of fuel: 10 gallons speed: 55 miles per hour license plate: “135 XJK” Second Instantiation: Object name: suesCar amount of fuel: 14 gallons speed: 0 miles per hour license plate: “SUES CAR” Third Instantiation: Object name: ronsCar amount of fuel: 2 gallons speed: 75 miles per hour license plate: “351 WLF”
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Objects Objects are variables that are named instances of a class the class is their type Objects have both data and methods Both the data items and methods of a class are members of the object Data items are also called fields or instance variables Invoking a method means to call the method, i.e. execute the method Syntax for invoking an object's method: the dot operator objectVariableName.method() objectVariableName is the calling (invoking) object
Background image of page 4
A class
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/13/2010 for the course CSE 114 taught by Professor Tashbook during the Spring '08 term at SUNY Stony Brook.

Page1 / 20

08ObjectsAndReference - CSE 114 Computer Science I Objects...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online