Chapter- 1 Introduction to Object-Oriented Programming
Chapter- 1 Introduction to Object-Oriented Programming
Oriented Programming
Functional Logic
Programming Programming
Algol Lisp Prolog Smalltalk
Cobol Haskell Simula
PL/1 ML C++ , C#
Ada Miranda Java ,VB
C APL
Modula-3
1. Objects
2. Classes
3. Methods and Messages
4. Abstraction
5. Inheritance
6. Encapsulation
7. Polymorphism
Object
Definition:
An object is a software bundle that has State and
Behavior.
Software Objects are often used to model real-world
objects.
Example:
dogs have states (name, color, hungry, breed) and
behaviors (bark, fetch, and wag tail).
Object Oriented Programming -
17
CoSc2051
Object Examples
Example 1: Dogs
States: name, color, breed, and “is hungry?”
Behaviors: bark, run, and wag tail
Example 2: Cars
States: color, model, speed, direction
Behaviors: accelerate, turn, change gears
base class /
derived class inherits parent class
Employee Student
+Company: String +School: String
+Salary: double
Concrete
class Square Circle
-x : int -x : int
-y : int -y : int
Overriden -size : int -radius: int Overriden
action action
Java Virtual
Machine
Any
Computer
compiler MAC
compiler
Win
System.out.println("Hello World!");
}
}
Save this file as HelloWorld.java (watch
capitalization) in the following directory:
c:\java
Result