Classes OOP
Classes OOP
(OOP)
Lecture No. 8
Course Objective
• Objective of this course is to make students
familiar with the concepts of object-oriented
programming
• Concepts will be reinforced by their
implementation in Java
• Project: (1) GUI + Database
(2) 3D Game design in Alice + Java
(3) Android Phone Programming
Course Contents
• Object-Orientation
• Objects and Classes
• Information Hiding
• Encapsulation
• Abstraction
• Inheritance
• Polymorphism
• Overloading vs Overriding
• General Java Programming
Books
Java Advanced How to Program
By Deitel & Deitel
Java 2--Complete Reference
By Herbert Schildt
Object-Oriented Software Engineering
By Jacobson, Christerson, Jonsson, Overgaard
Lecture Notes
What is Object-Orientation?
• Highway maps
• Architectural models
• Mechanical models
Example – OO Model
…Example – OO Model
lives-in
• Objects Ali House
– Ali
drives
– House
– Car
Car Tree
– Tree
• Interactions
– Ali lives in the house
– Ali drives the car
Object-Orientation - Advantages
An object is
An object has
• State (attributes)
• Well-defined behaviour (operations)
• Unique identity
• What is the relationship between a class and
an object?
• We don’t know
– How the data is stored
– How Ali translates this information
Other Example – Encapsulation
• A Phone stores phone numbers in digital
format and knows how to convert it into
human-readable characters
• We don’t know
– How the data is stored
– How it is converted to human-readable characters
Encapsulation – Advantages
• Low complexity
• Better understanding
Basic features of OOPs
• Abstraction - Refers to the process of exposing
only the relevant and essential data to the
users without showing unnecessary
information.
• Polymorphism - Allows you to use an entity in
multiple forms.
• Encapsulation - Prevents the data from
unwanted access by binding of code and data
in a single unit called object.
Basic features of OOPs
• Inheritance - Promotes the reusability of code
and eliminates the use of redundant code.
• It is the property through which a child class
obtains all the features defined in its parent
class.
• Data reusability and Extensibility
Object has an Interface
• This includes
– Data structures to hold object state
– Functionality that provides required services
Example – Implementation of Gear Box
• Data Structure
– Mechanical structure of gear box
• Functionality
– Mechanism to change gear
Example – Implementation of Address Book
in a Phone
• Data Structure
– SIM card
• Functionality
– Read/write circuitry
Questions !