SlideShare uma empresa Scribd logo
1 de 30
Object Oriented Programming
By – Hrishikesh Dhola
introduction of OOP by Hrishikesh Dhola
 Objects and classes
 Encapsulation and information hiding
 Mental exercises ,Classification and
exemplification , Aggregation and decomposition
, Generalization and specialization
 Inheritance
 Polymorphism and dynamic binding
 Java an example of an object-oriented
programming language , Program example ,
History of Java,Comparison to C/C+
introduction of OOP by Hrishikesh Dhola
 An object is an encapsulation of data.
 An object has
 Identity(a unique preference)
 social security number (cpr), employee
number, passport number
 Variables
 hungry, sad, drunk, running, alive
 Methods
 eat, drink, wave, smile, kiss
 An object is an instance of an class.
 A class is often called an Abstract Data Type
(ADT).
introduction of OOP by Hrishikesh Dhola
 A class is a collection of objects (or values) and a
corresponding set of methods.
 A class encapsulates the data representation and
makes data access possible at a higher level of
abstraction.
 Example 1: A set of vehicles with operations for
starting, stopping, driving, get km/liter, etc.
 Example 2: A time interval, start time, end
time, duration, overlapping intervals, etc.
 Example 3: A string, upper case, compare, lower
case, etc.
 Example of class : str.equals(otherStr) –
class/Java style
 Example of Class: strcmp(str, otherStr) – C style
introduction of OOP by Hrishikesh Dhola
 Data can be encapsulated such that it is
invisible to the “outside world”.
 Data can only be accessed via methods.
introduction of OOP by Hrishikesh Dhola
 What the “outside world” cannot see it cannot
depend on!
 The object is a “fire-wall” between the object
and the “outside world”.
 The hidden data and methods can be changed
without affecting the “outside world”.
introduction of OOP by Hrishikesh Dhola
 Class
 A description of the common properties of a set of
objects.
 A concept.
 A class is a part of a program.
 Example 1: Person
 Example 2: Album
 Object
 A representation of the properties of a single instance.
 A phenomenon.
 An object is part of data and a program execution.
 Example 1: Bill Clinton, Bono, Viggo Jensen.
 Example 2: A Hard Day's Night, Joshua Tree, Rickie Lee
Jones
introduction of OOP by Hrishikesh Dhola
 In object-oriented programming we write
classes
 The text files we create contain classes!
 Static
 “One”
 Objects are created from classes
 A class contains a “receipe” on how to make
objects
 Dynamic
 “Many”
introduction of OOP by Hrishikesh Dhola
 An object has type and an interface.
introduction of OOP by Hrishikesh Dhola
 An instantiation is a mechanism where objects
are created from a class.
 Always involves storage allocation for the
object.
 A mechanism where objects are given an initial
state.
 Static Instantiating
 In the declaration part of a program.
 A static instance is implicitly created.
 Dynamic Instantiating
 In the method part of a program.
 A dynamic instance is created explicitly with a special
command
introduction of OOP by Hrishikesh Dhola
 Interaction between objects happens by messages being send.
 A message activates a method on the calling object.
 An object O1 interacts with another object O2 by calling a method on O2
(must be part of the client interface).
 “O1 sends O2 a message”
 O1 and O2 must be related to communicate.
 The call of a method corresponds to a function (or procedure) call in a
non-object-oriented language such as C or Pascal.
introduction of OOP by Hrishikesh Dhola
 A phenomenon is a thing in the “real” world that
has individual existence.
 An Object
 A concept is a generalization, derived from a set
of phenomena and based on the common
properties of these phenomena.
 a class
 Characteristics of a concept
 A name
 Intension, the set of properties of the
phenomenon
 Extension, the set of phenomena covered by the
concept.
introduction of OOP by Hrishikesh Dhola
 hat, 23, 34, mouse, telephone, book, 98,
45.34, hello
 numbers: 23, 34, 98, 45.34
 words: hat, mouse, telephone, book, hello
 mouse, tyrannosaurus rex, allosaurus,
elephant, velociraptor
 dinosaur: tyrannosaurus rex, allosaurus,
velociraptor
 mammal: mouse, elephant
introduction of OOP by Hrishikesh Dhola
 A classification is a description of which
phenomena that belongs to a concept.
 An exemplification is a phenomenon that
covers the concept
introduction of OOP by Hrishikesh Dhola
 Idea: make new objects by combining
existing objects.
 Reusing the implementation!
introduction of OOP by Hrishikesh Dhola
 An aggregation consists of a number
of(sub)concepts which collectively is
considered a new concept.
 A decomposition splits a single concept into a
number of (sub-)concepts.
introduction of OOP by Hrishikesh Dhola
 Generalization creates a concept with a
broader scope.
 Specialization creates a concept with a
narrower scope.
introduction of OOP by Hrishikesh Dhola
 Inheritance: get the interface from the
general class.
 Objects related by inheritance are all of the
same type.
introduction of OOP by Hrishikesh Dhola
introduction of OOP by Hrishikesh Dhola
voiddoSomething(Shapes){
s.draw();// “magically” callsthespecificclass s.resize();
}
Circlec = new Circle();
Linel = new Line();
Rectangler = new Rectangle();
doSomething(c);// dynamicbinding
doSomething(l);
doSomething(r);
 Polymorphism: One piece of code works with all
shape objects.
 Dynamic binding: How polymorphism is
implemented.
introduction of OOP by Hrishikesh Dhola
 Take previous Shape class hierarchy
 remove inheritance
 remove general and abstract class Shape
introduction of OOP by Hrishikesh Dhola
introduction of OOP by Hrishikesh Dhola
/** A simple class modeling a car. */
public class Car {
// instance variables
private String make;
private String model;
private double price;
// constructor
public Car(String m, String mo, double p) {
make = m;
model = mo;
price = p;
}
// string representation of the car
public String toString() {
return "make: " + make + " model: "
+ model + " price: " + price;
}
}
introduction of OOP by Hrishikesh Dhola
introduction of OOP by Hrishikesh Dhola
 1990 Oak (interactive television, big failure)
 1994 Java (for the Internet)
 Main feature: "Write Once, Run Any Where" => wrap the
operating system so they all look the same
 Designed for
 A fresh start (no backward compatibility)
 “Pure” OOP: C++ Syntax, Smalltalk style
 Improvements over C++ much harder to write a bad program
 Internet programming Very hard to create a virus
 Run in a web browser (and at the server)
 There is a speed issue (from Java 1.3 and up much better)
 C# Microsoft's “Java-Killer” project release 2001
 Language very similar to Java
 Commen-Language Runtime (CLR) supports 30+ languages
introduction of OOP by Hrishikesh Dhola
 Everything resides in a class
 variables and methods
 Garbage collection
 bye bye malloc(), free(), and sizeof()
 Error and exception handling handling
 No global variables or methods
 No local static variables
 No separation of declaration and implementation
 Bye bye header files
 No explicit pointer operations (uses references)
 No preprocessor (but something similar)
 Has fewer “dark corners”
 Has a much larger standard library (Java Developer
Kit or JDK)
introduction of OOP by Hrishikesh Dhola
 Classes are “recipes” for creating objects
 All objects are instances of classes
 Encapsulation Key feature of object-oriented
programming
 Separation of interface from implementation
 It is not possible to access the hidden/encapsulated
parts of an object
 Aggregation and decomposition
 “has-a” relationship
 Generalization and specialization (inheritance)
 “is-a” or “is-like-a” relationship
 Polymorpishm/dynamic binding
 Softening static typing
introduction of OOP by Hrishikesh Dhola
// what is ugly here?
public class main {
public static void main(String[] args){
System.out.println(“Hello World”);}
}
// what is wrong here?
public class MyClass {
public void static main(string[] args){
System.out.println(“Hello World”);}
}
// what is ugly here?
public class MyClass {
public static void main(String[] args){
System.out.println(“Hello World”);}
};
introduction of OOP by Hrishikesh Dhola
 What are the actions of the program vs.
which data does the program act on.
 Top-down: Stepwise program refinement
 Bottom-up: Focus on the stable data parts
then add methods
 Object-oriented programming is bottom-up.
Programs are structure with outset in the
data.
 C and Pascal programs are typically implemented
in a more top-down fashion.
introduction of OOP by Hrishikesh Dhola
 Five rules [source: Alan Kay]
 Everything in an object.
 A program is a set of objects telling each
other what to do by sending messages.
 Each object has its own memory (made up
by other objects).
 Every object has a type.
 All objects of a specific type can receive the
same messages.
Java breaks some of these rules in the name of
efficiency.
introduction of OOP by Hrishikesh Dhola

Mais conteúdo relacionado

Mais procurados

Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop)   cs304 power point slides lecture 01Object oriented programming (oop)   cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01Adil Kakakhel
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingmustafa sarac
 
Java object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - BrainsmartlabsJava object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - Brainsmartlabsbrainsmartlabsedu
 
Ruby OOP: Objects over Classes
Ruby OOP: Objects over ClassesRuby OOP: Objects over Classes
Ruby OOP: Objects over ClassesAman King
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming ConceptsBhushan Nagaraj
 
OOPs concept and implementation
OOPs concept and implementationOOPs concept and implementation
OOPs concept and implementationSandeep Kumar P K
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaTeaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaDr. Sandeep Kumar Singh
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Michael Redlich
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPTkishu0005
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMd. Tanvir Hossain
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentEduardo Bergavera
 
Python Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and PolymorphismPython Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and PolymorphismRanel Padon
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objectsrahulsahay19
 
CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONLalitkumar_98
 

Mais procurados (20)

Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop)   cs304 power point slides lecture 01Object oriented programming (oop)   cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Oops in java
Oops in javaOops in java
Oops in java
 
OOPS in Java
OOPS in JavaOOPS in Java
OOPS in Java
 
Java object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - BrainsmartlabsJava object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - Brainsmartlabs
 
Ruby OOP: Objects over Classes
Ruby OOP: Objects over ClassesRuby OOP: Objects over Classes
Ruby OOP: Objects over Classes
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
OOPs concept and implementation
OOPs concept and implementationOOPs concept and implementation
OOPs concept and implementation
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaTeaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software Development
 
Python Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and PolymorphismPython Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and Polymorphism
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objects
 
Introduction to OOP(in java) BY Govind Singh
Introduction to OOP(in java)  BY Govind SinghIntroduction to OOP(in java)  BY Govind Singh
Introduction to OOP(in java) BY Govind Singh
 
CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHON
 

Semelhante a OOP by hrishikesh dhola

Object And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesObject And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesJessica Deakin
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideSharebiyu
 
Oop.concepts
Oop.conceptsOop.concepts
Oop.conceptstahir266
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHPHerman Peeren
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaMadishetty Prathibha
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid DeconstructionKevlin Henney
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that WordKevlin Henney
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingAhmed Swilam
 
Java for android developers
Java for android developersJava for android developers
Java for android developersAly Abdelkareem
 
JAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxJAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxayankamila005
 
It Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in JavaIt Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in JavaKevlin Henney
 

Semelhante a OOP by hrishikesh dhola (20)

SEMINAR
SEMINARSEMINAR
SEMINAR
 
Seminar
SeminarSeminar
Seminar
 
Object And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesObject And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) Languages
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideShare
 
Oop.concepts
Oop.conceptsOop.concepts
Oop.concepts
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHP
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Object
ObjectObject
Object
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid Deconstruction
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that Word
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
Java for android developers
Java for android developersJava for android developers
Java for android developers
 
JAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxJAVA - Oops Concept.pptx
JAVA - Oops Concept.pptx
 
Java oo ps concepts
Java oo ps conceptsJava oo ps concepts
Java oo ps concepts
 
Oop basic concepts
Oop basic conceptsOop basic concepts
Oop basic concepts
 
Java pdf
Java   pdfJava   pdf
Java pdf
 
It Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in JavaIt Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in Java
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

OOP by hrishikesh dhola

  • 1. Object Oriented Programming By – Hrishikesh Dhola introduction of OOP by Hrishikesh Dhola
  • 2.  Objects and classes  Encapsulation and information hiding  Mental exercises ,Classification and exemplification , Aggregation and decomposition , Generalization and specialization  Inheritance  Polymorphism and dynamic binding  Java an example of an object-oriented programming language , Program example , History of Java,Comparison to C/C+ introduction of OOP by Hrishikesh Dhola
  • 3.  An object is an encapsulation of data.  An object has  Identity(a unique preference)  social security number (cpr), employee number, passport number  Variables  hungry, sad, drunk, running, alive  Methods  eat, drink, wave, smile, kiss  An object is an instance of an class.  A class is often called an Abstract Data Type (ADT). introduction of OOP by Hrishikesh Dhola
  • 4.  A class is a collection of objects (or values) and a corresponding set of methods.  A class encapsulates the data representation and makes data access possible at a higher level of abstraction.  Example 1: A set of vehicles with operations for starting, stopping, driving, get km/liter, etc.  Example 2: A time interval, start time, end time, duration, overlapping intervals, etc.  Example 3: A string, upper case, compare, lower case, etc.  Example of class : str.equals(otherStr) – class/Java style  Example of Class: strcmp(str, otherStr) – C style introduction of OOP by Hrishikesh Dhola
  • 5.  Data can be encapsulated such that it is invisible to the “outside world”.  Data can only be accessed via methods. introduction of OOP by Hrishikesh Dhola
  • 6.  What the “outside world” cannot see it cannot depend on!  The object is a “fire-wall” between the object and the “outside world”.  The hidden data and methods can be changed without affecting the “outside world”. introduction of OOP by Hrishikesh Dhola
  • 7.  Class  A description of the common properties of a set of objects.  A concept.  A class is a part of a program.  Example 1: Person  Example 2: Album  Object  A representation of the properties of a single instance.  A phenomenon.  An object is part of data and a program execution.  Example 1: Bill Clinton, Bono, Viggo Jensen.  Example 2: A Hard Day's Night, Joshua Tree, Rickie Lee Jones introduction of OOP by Hrishikesh Dhola
  • 8.  In object-oriented programming we write classes  The text files we create contain classes!  Static  “One”  Objects are created from classes  A class contains a “receipe” on how to make objects  Dynamic  “Many” introduction of OOP by Hrishikesh Dhola
  • 9.  An object has type and an interface. introduction of OOP by Hrishikesh Dhola
  • 10.  An instantiation is a mechanism where objects are created from a class.  Always involves storage allocation for the object.  A mechanism where objects are given an initial state.  Static Instantiating  In the declaration part of a program.  A static instance is implicitly created.  Dynamic Instantiating  In the method part of a program.  A dynamic instance is created explicitly with a special command introduction of OOP by Hrishikesh Dhola
  • 11.  Interaction between objects happens by messages being send.  A message activates a method on the calling object.  An object O1 interacts with another object O2 by calling a method on O2 (must be part of the client interface).  “O1 sends O2 a message”  O1 and O2 must be related to communicate.  The call of a method corresponds to a function (or procedure) call in a non-object-oriented language such as C or Pascal. introduction of OOP by Hrishikesh Dhola
  • 12.  A phenomenon is a thing in the “real” world that has individual existence.  An Object  A concept is a generalization, derived from a set of phenomena and based on the common properties of these phenomena.  a class  Characteristics of a concept  A name  Intension, the set of properties of the phenomenon  Extension, the set of phenomena covered by the concept. introduction of OOP by Hrishikesh Dhola
  • 13.  hat, 23, 34, mouse, telephone, book, 98, 45.34, hello  numbers: 23, 34, 98, 45.34  words: hat, mouse, telephone, book, hello  mouse, tyrannosaurus rex, allosaurus, elephant, velociraptor  dinosaur: tyrannosaurus rex, allosaurus, velociraptor  mammal: mouse, elephant introduction of OOP by Hrishikesh Dhola
  • 14.  A classification is a description of which phenomena that belongs to a concept.  An exemplification is a phenomenon that covers the concept introduction of OOP by Hrishikesh Dhola
  • 15.  Idea: make new objects by combining existing objects.  Reusing the implementation! introduction of OOP by Hrishikesh Dhola
  • 16.  An aggregation consists of a number of(sub)concepts which collectively is considered a new concept.  A decomposition splits a single concept into a number of (sub-)concepts. introduction of OOP by Hrishikesh Dhola
  • 17.  Generalization creates a concept with a broader scope.  Specialization creates a concept with a narrower scope. introduction of OOP by Hrishikesh Dhola
  • 18.  Inheritance: get the interface from the general class.  Objects related by inheritance are all of the same type. introduction of OOP by Hrishikesh Dhola
  • 19. introduction of OOP by Hrishikesh Dhola
  • 20. voiddoSomething(Shapes){ s.draw();// “magically” callsthespecificclass s.resize(); } Circlec = new Circle(); Linel = new Line(); Rectangler = new Rectangle(); doSomething(c);// dynamicbinding doSomething(l); doSomething(r);  Polymorphism: One piece of code works with all shape objects.  Dynamic binding: How polymorphism is implemented. introduction of OOP by Hrishikesh Dhola
  • 21.  Take previous Shape class hierarchy  remove inheritance  remove general and abstract class Shape introduction of OOP by Hrishikesh Dhola
  • 22. introduction of OOP by Hrishikesh Dhola
  • 23. /** A simple class modeling a car. */ public class Car { // instance variables private String make; private String model; private double price; // constructor public Car(String m, String mo, double p) { make = m; model = mo; price = p; } // string representation of the car public String toString() { return "make: " + make + " model: " + model + " price: " + price; } } introduction of OOP by Hrishikesh Dhola
  • 24. introduction of OOP by Hrishikesh Dhola
  • 25.  1990 Oak (interactive television, big failure)  1994 Java (for the Internet)  Main feature: "Write Once, Run Any Where" => wrap the operating system so they all look the same  Designed for  A fresh start (no backward compatibility)  “Pure” OOP: C++ Syntax, Smalltalk style  Improvements over C++ much harder to write a bad program  Internet programming Very hard to create a virus  Run in a web browser (and at the server)  There is a speed issue (from Java 1.3 and up much better)  C# Microsoft's “Java-Killer” project release 2001  Language very similar to Java  Commen-Language Runtime (CLR) supports 30+ languages introduction of OOP by Hrishikesh Dhola
  • 26.  Everything resides in a class  variables and methods  Garbage collection  bye bye malloc(), free(), and sizeof()  Error and exception handling handling  No global variables or methods  No local static variables  No separation of declaration and implementation  Bye bye header files  No explicit pointer operations (uses references)  No preprocessor (but something similar)  Has fewer “dark corners”  Has a much larger standard library (Java Developer Kit or JDK) introduction of OOP by Hrishikesh Dhola
  • 27.  Classes are “recipes” for creating objects  All objects are instances of classes  Encapsulation Key feature of object-oriented programming  Separation of interface from implementation  It is not possible to access the hidden/encapsulated parts of an object  Aggregation and decomposition  “has-a” relationship  Generalization and specialization (inheritance)  “is-a” or “is-like-a” relationship  Polymorpishm/dynamic binding  Softening static typing introduction of OOP by Hrishikesh Dhola
  • 28. // what is ugly here? public class main { public static void main(String[] args){ System.out.println(“Hello World”);} } // what is wrong here? public class MyClass { public void static main(string[] args){ System.out.println(“Hello World”);} } // what is ugly here? public class MyClass { public static void main(String[] args){ System.out.println(“Hello World”);} }; introduction of OOP by Hrishikesh Dhola
  • 29.  What are the actions of the program vs. which data does the program act on.  Top-down: Stepwise program refinement  Bottom-up: Focus on the stable data parts then add methods  Object-oriented programming is bottom-up. Programs are structure with outset in the data.  C and Pascal programs are typically implemented in a more top-down fashion. introduction of OOP by Hrishikesh Dhola
  • 30.  Five rules [source: Alan Kay]  Everything in an object.  A program is a set of objects telling each other what to do by sending messages.  Each object has its own memory (made up by other objects).  Every object has a type.  All objects of a specific type can receive the same messages. Java breaks some of these rules in the name of efficiency. introduction of OOP by Hrishikesh Dhola