Presentation is loading. Please wait.

Presentation is loading. Please wait.

AP Computer Science A – Healdsburg High School 1 Unit 2 - Object-Oriented Programming - Example.

Similar presentations


Presentation on theme: "AP Computer Science A – Healdsburg High School 1 Unit 2 - Object-Oriented Programming - Example."— Presentation transcript:

1

2 AP Computer Science A – Healdsburg High School 1 Unit 2 - Object-Oriented Programming - Example

3 AP Computer Science A – Healdsburg High School 2 OOP — Object-Oriented Programming An OOP program models a world of active objects. An object may have its own “memory,” which may contain other objects. An object has a set of methods that can process messages of certain types.

4 AP Computer Science A – Healdsburg High School 3 OOP (cont’d) A method can change the object’s state, send messages to other objects, and create new objects. An object belongs to a particular class, and the functionality of each object is determined by its class. A programmer creates an OOP application by defining classes.

5 AP Computer Science A – Healdsburg High School 4 The Main OOP Concepts: Inheritance: a subclass extends a superclass; the objects of a subclass inherit features of the superclass and can redefine them or add new features. Event-driven programs: the program simulates asynchronous handling of events; methods are called automatically in response to events.

6 AP Computer Science A – Healdsburg High School 5 Inheritance A programmer can define hierarchies of classes More general classes are closer to the top Person ChildAdult BabyToddlerTeen

7 AP Computer Science A – Healdsburg High School import java.awt.Color; public class Hexagon { public static void main (String [ ] args) { Turtle t; t = new Turtle(); Declare and construct an object of type Turtle. Ex. Using the Turtle class, create a Turtle object and “command” that Turtle object to draw a hexagon with side length 50 pixels.


Download ppt "AP Computer Science A – Healdsburg High School 1 Unit 2 - Object-Oriented Programming - Example."

Similar presentations


Ads by Google