Lecture 1 Introduction To Object Oriented Programming Approach
Lecture 1 Introduction To Object Oriented Programming Approach
WITH JAVA(JAV61US)
LECTURE 1: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
1. OOP Concepts
2. Rapid Prototyping
3. User Interface Design
4. Java Development Environment
5. Basic Java Syntax
6. Control Constructs
7. Logic
8. Arrays
9. Functions
10. Creating and using classes
11. Exploring object-oriented programming in Java
12. Java Error Handling
13. Dealing with Text Files in Java
RECOMMENDED TEXT
Learn the principles of OOP which are encapsulation, inheritance and polymorphism.
Learn how to create OO models such as object diagrams, class diagrams, use case
diagrams, state chart diagrams, and sequence diagrams.
OBJECT-ORIENTED PROGRAMMING
OOP is a programming paradigm that uses abstraction (in the form of classes and
Objects are capable of passing messages, receiving messages, and processing data.
OOP programs are modular hence easier to develop, and simpler to understand.
CLASSES
Objects have:
State (attributes/properties)
Behaviour (methods/functions)
Identity (distinct)
EXAMPLE OF A CLASS
AND OBJECTS
SIMILAR TERMINOLOGIES
instance = object
field = instance/object variable
method = function
sending a message to an object = calling a function
15
PRINCIPLES OF OBJECT ORIENTED PROGRAMMING
Encapsulation
Inheritance
Polymorphism
ENCAPSULATION
Encapsulation protects data from being accessed by the outside world (other classes
within the application).
Only functions which are defined in a class can access the data in that class.
ENCAPSULATION
Protection of data
Data consistency
A class that is derived from another class is called a subclass (also known as child
class, extended class or derived class).
The class from which the subclass if derived is called a super class, parent class
or base class.
The subclass inherits all data members and functions that belong to its super class.
The subclass also have data members and functions of its own (not inherited from
the super class).
TYPES OF
INHERITANCE
CLASS INHERITANCE EXAMPLE
EXAMPLE OF INHERITANCE
class Person { class Employee
String name; extends Person {
int age; double salary;
void birthday () { void pay () { ...}
age = age + 1; }
}
}
The most common use of polymorphism in OOP occurs when a parent class
reference is used to refer to a child class object (multiple inheritance).
Any Java object that can pass more than one IS-A test is considered to be
polymorphic.
All Java objects are polymorphic since any object will pass the IS-A test for their
own type and for the class Object.
POLYMORPHISM