Lec09 - Lecture 9 Objects and classes Constructing objects Instance variables Methods(Savitch 4.1 CS125 Course Notes Lecture 9 Slide 1 Object A

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

View Full Document Right Arrow Icon
CS125 Course Notes Lecture 9, Slide 1 Lecture 9 • Objects and classes • Constructing objects • Instance variables • Methods (Savitch 4.1)
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 9, Slide 2 Object • A Java program consists of interacting objects. • An object models a thing (real or abstract). It has values (attributes) and operations (methods). • A class in Java is the code which details how to create (instantiate) an object of the class and includes the set of associated operations. A “template.” • An object is an instance of a class
Background image of page 2
CS125 Course Notes Lecture 9, Slide 3 Example of an object • A GameBoy™ is a handheld, electronic toy. • It has a screen, buttons, a colour, and may contain a game cartridge (data). • A player can turn it on and off, load a game, play a game and recharge the battery (operations).
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 9, Slide 4 Instantiating an object • Syntax: Class_Type Name = new Class_Type (); Examples: Scanner input = new Scanner(System.in); GameBoy myGame = new GameBoy();
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/27/2009 for the course MATH 135 taught by Professor Andrewchilds during the Fall '08 term at Waterloo.

Page1 / 16

Lec09 - Lecture 9 Objects and classes Constructing objects Instance variables Methods(Savitch 4.1 CS125 Course Notes Lecture 9 Slide 1 Object A

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

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