SlideShare a Scribd company logo
1 of 26
eACCP/Object Oriented Concepts and Java 2/Session 1/ 1 of 26
Object Oriented Programming
Approach
Session I
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 2 of 26
Session Objectives
 Explain structured programming and its
drawbacks
 Discuss Object Oriented Programming and its
advantages
 Define classes and objects
 Identify properties and methods
 Explain public and private sections of a class
 Discuss abstraction and encapsulation
 Describe inheritance and polymorphism
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 3 of 26
Structured Programming - I
mainprg()
{
Print “Hello World”
result = 13*12/2.5
Print “Result =” result
}
Program is a set of tasks
Broken down into
smaller and independent
functions
Structured programming follows a ‘top-down’ approach
sometimes termed as ‘step-wise refinement’.
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 4 of 26
Structured Programming - II
 A program is organised into a hierarchy of
modules
 Each module or function has a single entry
and exit point
 Three types of control flow:
 Sequential
 Test
 Iteration
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 5 of 26
Disadvantages of Structured
Programming
 Difficult to separate data from functions
that manipulate it
 Solutions are recreated and not reused
 Difficult to track and manage changes
Object oriented programming provides techniques for
managing complexity and reuse of software
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 6 of 26
The Object Oriented Approach -I
 Object oriented programming grew in the
70’s as a solution to the problems of
structured programming
 Models human thought process as closely as
possible
 Deals with data and procedures that operate
on data as a single ‘object’
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 7 of 26
The Object Oriented Approach - II
All around us in the real world are
objects.
Each object has certain
characteristics and exhibits
certain behaviour
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 8 of 26
The OO Approach - An Example
Top-Down approach OOP
We are going to build a hotel We are going to build a 10
storey hotel with ordinary,
deluxe and luxury suites
that also possesses an
executive lecture hall
We are going to then design
several floors, rooms and
then the lecture hall
We are going to build a
hotel along these
specifications(components)
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 9 of 26
The OO Methodology
The four steps in this methodology are:
 Identify the problem
 Identify the objects needed for the solution
 Identify the messages to be sent to the
object
 Create a sequence of messages to the
objects that solve the problem
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 10 of 26
Object Oriented Programming
OOP (Object oriented Programming) offers a powerful
model for writing software. Here:
Accounts
Data:
•No. of employees
•Salary statements
•Bills
•Vouchers
•Receipts
•Petty cash records
•Banking data
Functions:
•Calculate salary
•Pay salary
•Pay bills
•Tally accounts
•Transact with
banks
Code & Data
Object
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 11 of 26
Basic Object Oriented Concepts
 Object
 Helps to understand the real world
 Provides a practical basis for computer applications
 Class
 Describes a set of related objects
 Property
 A characteristic of an object – also called attribute
 Method
 An action performed by an object
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 12 of 26
Abstraction - I
 A process of examining certain aspects of a
problem as relevant to a particular
application
Method 1
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 13 of 26
Abstraction - II
Abstraction is classified into two
 Data abstraction
 Identifying the properties related to a particular
application
 Procedural abstraction
 Applying focus on the arguments and the return
value of the procedure rather than its
implementation
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 14 of 26
Inheritance
Inheritance is a
property that
allows reuse of
an existing
class to build
a new class
Animals
Reusability can be
achieved through
inheritance
Insects Mammals Reptiles Amphibians
Humans Non-Humans
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 15 of 26
Reusability
Programs can be broken
into reusable objects
Existing classes can be
used with additional
features
Shape
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 16 of 26
Encapsulation
 A process of information hiding
 Selective hiding of data
 Prevents accidental tampering of data
 Errors are easier to isolate and fix
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 17 of 26
Polymorphism
 Same functions with different behaviour on
different classes
Class -
Artiste
Dancer Poet
Sculptor
Here, a method
method perform()
implemented on the
subclasses would
give different results
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 18 of 26
More on Classes
 A class contains
 Data members
 Functions
 Data members are accessed through the
functions
 An object is an instance of a class
 A class can have sections which are not
accessible to other classes
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 19 of 26
A Class Definition
class Animal
{
public int noOfLegs;
public String name;
private char gender;
public void showData()
{
display(“Name :” + name);
display(“Number of Legs:” + noOfLegs );
display(“Gender :” + gender);
}
}
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 20 of 26
Access Specifiers of a Class
Class
Data or
functions
Data or
functions
Private
Public
Not
accessible
from outside
the class
Accessible
from outside
the class
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 21 of 26
Member Function
 Is a message to an object
 Is usually declared public
 Should not have the same name as a data
member
 Provides access to the data members of a
class
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 22 of 26
Using the Class
 Instantiating a class
 Animal anim1=new Animal();
 Assigning values
 anim1.name = “zebra”;
 Calling member functions
 anim1.showData();
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 23 of 26
Passing and Returning Objects
Compiler
creates a
FORMAL
variable in
the called
function
All data members of the object are copied to the
formal variable and they can be assigned any value
Formal
variables
Function
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 24 of 26
Object Oriented Languages
 Some of the leading object oriented
languages are:
 C++
 Smalltalk
 Eiffel
 CLOS
 Java
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 25 of 26
What is Java ?
Java is a high level programming
language introduced by Sun
Microsystems in June 1995
It provides for interactive processing and for the use of
graphics and animation on the Internet.
James Gosling
It was developed by a team under
James Gosling
eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 26 of 26
Features of Java
 Simple
 Object oriented
 Platform independent
 Robust
 Secure
 Distributed
 Multithreaded
 Dynamic

More Related Content

Similar to 1Intro.PPT

Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingAhmed Swilam
 
C#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentC#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentSVRTechnologies
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindiappsdevelopment
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptxSajidTk2
 
Object Oriented Javascript part2
Object Oriented Javascript part2Object Oriented Javascript part2
Object Oriented Javascript part2Usman Mehmood
 
CS8592 Object Oriented Analysis & Design - UNIT I
CS8592 Object Oriented Analysis & Design - UNIT ICS8592 Object Oriented Analysis & Design - UNIT I
CS8592 Object Oriented Analysis & Design - UNIT Ipkaviya
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptxrani marri
 
Reflection in java
Reflection in javaReflection in java
Reflection in javaupen.rockin
 
Core java-introduction
Core java-introductionCore java-introduction
Core java-introductionRamlal Pawar
 
Java programming concept
Java programming conceptJava programming concept
Java programming conceptSanjay Gunjal
 
OOAD unit1 introduction to object orientation
 OOAD unit1 introduction to object orientation OOAD unit1 introduction to object orientation
OOAD unit1 introduction to object orientationDr Chetan Shelke
 

Similar to 1Intro.PPT (20)

Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
C#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentC#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course Content
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptx
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
Object Oriented Javascript part2
Object Oriented Javascript part2Object Oriented Javascript part2
Object Oriented Javascript part2
 
CS8592 Object Oriented Analysis & Design - UNIT I
CS8592 Object Oriented Analysis & Design - UNIT ICS8592 Object Oriented Analysis & Design - UNIT I
CS8592 Object Oriented Analysis & Design - UNIT I
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
 
Reflection in java
Reflection in javaReflection in java
Reflection in java
 
01slide
01slide01slide
01slide
 
Core java-introduction
Core java-introductionCore java-introduction
Core java-introduction
 
Oops
OopsOops
Oops
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
 
Presentation5
Presentation5Presentation5
Presentation5
 
A Multi-level Methodology for Developing UML Sequence Diagrams
A Multi-level Methodology for Developing UML Sequence DiagramsA Multi-level Methodology for Developing UML Sequence Diagrams
A Multi-level Methodology for Developing UML Sequence Diagrams
 
Object
ObjectObject
Object
 
OOAD unit1 introduction to object orientation
 OOAD unit1 introduction to object orientation OOAD unit1 introduction to object orientation
OOAD unit1 introduction to object orientation
 
Chapter02
Chapter02Chapter02
Chapter02
 

Recently uploaded

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfKartik Tiwari
 
Pharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdfPharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdfBALASUNDARESAN M
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxMichaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxRugvedSathawane
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 

Recently uploaded (20)

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
Pharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdfPharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxMichaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 

1Intro.PPT

  • 1. eACCP/Object Oriented Concepts and Java 2/Session 1/ 1 of 26 Object Oriented Programming Approach Session I
  • 2. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 2 of 26 Session Objectives  Explain structured programming and its drawbacks  Discuss Object Oriented Programming and its advantages  Define classes and objects  Identify properties and methods  Explain public and private sections of a class  Discuss abstraction and encapsulation  Describe inheritance and polymorphism
  • 3. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 3 of 26 Structured Programming - I mainprg() { Print “Hello World” result = 13*12/2.5 Print “Result =” result } Program is a set of tasks Broken down into smaller and independent functions Structured programming follows a ‘top-down’ approach sometimes termed as ‘step-wise refinement’.
  • 4. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 4 of 26 Structured Programming - II  A program is organised into a hierarchy of modules  Each module or function has a single entry and exit point  Three types of control flow:  Sequential  Test  Iteration
  • 5. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 5 of 26 Disadvantages of Structured Programming  Difficult to separate data from functions that manipulate it  Solutions are recreated and not reused  Difficult to track and manage changes Object oriented programming provides techniques for managing complexity and reuse of software
  • 6. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 6 of 26 The Object Oriented Approach -I  Object oriented programming grew in the 70’s as a solution to the problems of structured programming  Models human thought process as closely as possible  Deals with data and procedures that operate on data as a single ‘object’
  • 7. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 7 of 26 The Object Oriented Approach - II All around us in the real world are objects. Each object has certain characteristics and exhibits certain behaviour
  • 8. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 8 of 26 The OO Approach - An Example Top-Down approach OOP We are going to build a hotel We are going to build a 10 storey hotel with ordinary, deluxe and luxury suites that also possesses an executive lecture hall We are going to then design several floors, rooms and then the lecture hall We are going to build a hotel along these specifications(components)
  • 9. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 9 of 26 The OO Methodology The four steps in this methodology are:  Identify the problem  Identify the objects needed for the solution  Identify the messages to be sent to the object  Create a sequence of messages to the objects that solve the problem
  • 10. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 10 of 26 Object Oriented Programming OOP (Object oriented Programming) offers a powerful model for writing software. Here: Accounts Data: •No. of employees •Salary statements •Bills •Vouchers •Receipts •Petty cash records •Banking data Functions: •Calculate salary •Pay salary •Pay bills •Tally accounts •Transact with banks Code & Data Object
  • 11. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 11 of 26 Basic Object Oriented Concepts  Object  Helps to understand the real world  Provides a practical basis for computer applications  Class  Describes a set of related objects  Property  A characteristic of an object – also called attribute  Method  An action performed by an object
  • 12. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 12 of 26 Abstraction - I  A process of examining certain aspects of a problem as relevant to a particular application Method 1
  • 13. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 13 of 26 Abstraction - II Abstraction is classified into two  Data abstraction  Identifying the properties related to a particular application  Procedural abstraction  Applying focus on the arguments and the return value of the procedure rather than its implementation
  • 14. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 14 of 26 Inheritance Inheritance is a property that allows reuse of an existing class to build a new class Animals Reusability can be achieved through inheritance Insects Mammals Reptiles Amphibians Humans Non-Humans
  • 15. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 15 of 26 Reusability Programs can be broken into reusable objects Existing classes can be used with additional features Shape
  • 16. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 16 of 26 Encapsulation  A process of information hiding  Selective hiding of data  Prevents accidental tampering of data  Errors are easier to isolate and fix
  • 17. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 17 of 26 Polymorphism  Same functions with different behaviour on different classes Class - Artiste Dancer Poet Sculptor Here, a method method perform() implemented on the subclasses would give different results
  • 18. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 18 of 26 More on Classes  A class contains  Data members  Functions  Data members are accessed through the functions  An object is an instance of a class  A class can have sections which are not accessible to other classes
  • 19. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 19 of 26 A Class Definition class Animal { public int noOfLegs; public String name; private char gender; public void showData() { display(“Name :” + name); display(“Number of Legs:” + noOfLegs ); display(“Gender :” + gender); } }
  • 20. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 20 of 26 Access Specifiers of a Class Class Data or functions Data or functions Private Public Not accessible from outside the class Accessible from outside the class
  • 21. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 21 of 26 Member Function  Is a message to an object  Is usually declared public  Should not have the same name as a data member  Provides access to the data members of a class
  • 22. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 22 of 26 Using the Class  Instantiating a class  Animal anim1=new Animal();  Assigning values  anim1.name = “zebra”;  Calling member functions  anim1.showData();
  • 23. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 23 of 26 Passing and Returning Objects Compiler creates a FORMAL variable in the called function All data members of the object are copied to the formal variable and they can be assigned any value Formal variables Function
  • 24. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 24 of 26 Object Oriented Languages  Some of the leading object oriented languages are:  C++  Smalltalk  Eiffel  CLOS  Java
  • 25. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 25 of 26 What is Java ? Java is a high level programming language introduced by Sun Microsystems in June 1995 It provides for interactive processing and for the use of graphics and animation on the Internet. James Gosling It was developed by a team under James Gosling
  • 26. eACCP/ Object Oriented Concepts and Java 2/ Session 1/ 26 of 26 Features of Java  Simple  Object oriented  Platform independent  Robust  Secure  Distributed  Multithreaded  Dynamic