Download presentation
Presentation is loading. Please wait.
Published byBarbra Lester Modified over 9 years ago
2
Object-Oriented Programming (Review) CS 123
3
Key OOP Concepts zObject, Class zInstantiation, Constructors zEncapsulation zInheritance and Subclasses zAbstraction zReuse zPolymorphism, Dynamic Binding
4
Object Definition: a thing that has identity, state, and behavior Õidentity: a distinguished instance of a class Õstate: collection of values for its variables Õbehavior: capability to execute methods * variables and methods are defined in a class
5
Class Definition: a collection of data (fields/ variales) and methods that operate on that data Õdata/methods define the contents/capabilities of the instances (objects) of the class Õa class can be viewed as a factory for objects Õa class defines a recipe for its objects
6
Instantiation zObject creation zMemory is allocated for the object’s fields as defined in the class zInitialization is specified through a constructor Õa special method invoked when objects are created
7
Encapsulation zA key OO concept: “Information Hiding” zKey points ÕThe user of an object should have access only to those methods (or data) that are essential ÕUnnecessary implementation details should be hidden from the user ÕIn Java/C++, use classes and access modifiers (public, private, protected)
8
Inheritance zInheritance: Õprogramming language feature that allows for the implicit definition of variables/methods for a class through an existing class zSubclass relationship ÕB is a subclass of A ÕB inherits all definitions (variables/methods) in A
9
Abstraction zOOP is about abstraction zEncapsulation and Inheritance are examples of abstraction ÕWhat does the verb “abstract” mean?
10
Reuse zInheritance encourages software reuse zExisting code need not be rewritten zSuccessful reuse occurs only through careful planning and design Õwhen defining classes, anticipate future modifications and extensions
11
Polymorphism z“Many forms” Õallow several definitions under a single method name zExample: Õ“move” means something for a person object but means something else for a car object zDynamic binding: Õcapability of an implementation to distinguish between the different forms during run-time
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.