CH01 - Chapter 1 Java an Introduction to Computer...

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Chapter 1 Introduction to Java Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Object-Oriented Programming: OOP ● Design and programming technique ● Terminology: » object – – usually a person, place or thing (a noun) – Example: ● Isuzu rodeo » method – – an action performed by an object (a verb) – Example ● IsDriven(driver, start,stop,speed) » type or class – – a category of similar objects – Example: ● automobiles Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Objects in OOP ● Objects have » Data – Make: Isuzu – Model: Rodeo » Methods – isDriven from Boston to Cambridge ● Objects of same class » Same data elements » Same methods ● Objects » Send and receive messages to invoke actions Make Model IsDriven() Make: Isuzu Model: Rodeo isDriven() Make: Honda Model: Civic isDriven() Object: Car1 Type: Automobile Object: Car2 Type: Automobile Class: Automobile Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Example of a Class Data Items: » manufacturer’s name » model name » year made » color » number of doors » size of engine » etc. Methods: » Define data items (specify manufacturer’s name, model, year, etc.) » Change a data item (color, engine, etc.) » Display data items » Calculate cost » etc. Class: Automobile Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Why OOP? ● Save development time (and cost) by reusing code » once class created => used in other applications ● Easier debugging » classes – tested independently » reused objects – already been tested Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Design Principles of OOP ● Encapsulation ● Polymorphism ● Inheritance Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Encapsulation Definition » Design software so can be used without knowing details » Also known as information hiding Analogy: » Driving a car, don’t know details of – how many cylinders the engine has – how the gasoline and air are mixed and ignited. » Only have to know how to use the controls. details Interfa c e World Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Polymorphism ● Definition » Same word or phrase mean different things in different contexts ● Example In Java » Two or more classes could have print method » Each print method do actions the class that it’s in. Class: Auto Class: Employee Print() // Prints all about Employee Print() // Prints all about auto Chapter 1 Java: an Introduction to Computer Science & Programming - Walter Savitch Inheritance ● Definition » Heirarchical way of organizing classes ● Analogy » Humans inherit properties of mammals ....
View Full Document

{[ snackBarMessage ]}

Page1 / 57

CH01 - Chapter 1 Java an Introduction to Computer...

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

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