SlideShare une entreprise Scribd logo
1  sur  15
Lecture by Niko Adrianus Yuwono
 Objects are key to understanding object-
oriented programming.
 Objects are like real-world objects like cat or
car
 Real-world objects share two characteristics:
They all have state and behavior.
 For example cats have state (name, color,
breed, hungry) and behavior (meowing,
fetching, wagging tail, playing).
 Same as real-world object, object in
programming also have that two
characteristics : state (fields) and behavior
(methods)
 Hiding internal state and requiring all
interaction to be performed through an
object's methods is known as data
encapsulation — a fundamental principle of
object-oriented programming.
 In the real world, you'll often find many individual
objects all of the same kind. There may be
thousands of other cats in existence, but all of
them have same state and behaviour.
 That’s why we use class to classify them.
 Objects of the same kind are said to be members
of the same class.
 Let’s say there are Angora Cat, Persian Cat and
Common Cat. All of them are members of Cat
class and they have same basic state and
behaviour.
 Furthermore, if we want to make the
classification bigger we can use Inheritance
 Imagine a class with a very big scope let’s say
we have a class named Animal that have
fields legs, isHungry, isAlive, etc and methods
eat, sleep, etc
 The attribute in the class Animal can be
inherited to their sub/child class
 For example we’ve a class named cats that
extends to animal class
 That means animal class is the parent/super
class of cats class
 Cat class will get all the same fields and
methods as animal class
 However, you must take care to properly
document the state and behavior that each
superclass defines, since that code will not
appear in the source file of each subclass.
 This is a table of access member control that
define which member of the class can be
accessed
Access Levels
Modifier Class Package Subclass World
public Y Y Y Y
protected Y Y Y N
no modifier Y Y N N
private Y N N N
 Polymorphism describes a pattern in object
oriented programming in which classes have
different functionality while sharing a
common interface.
 An interface is similar to a class except that it
cannot contain code. An interface can define
method names and arguments, but not the
contents of the methods.
 Any classes implementing an interface must
implement all methods defined by the
interface.
 Objective-C
 @interface Forwarder : Object
 {
 id someFields;
 }
 - (id) someMethod;
 @end
 PHP
 interface InterfaceExample {
 public function doSomething();
 public function doEverything();
 }
 Java
 interface Animal{
 void eat(String what);
 void sleep(int time);
 void mate(String withWho); }
 Method overloading deals with the notion of
having two or more methods(functions) in the
same class with the same name but different
arguments.
 While Method overriding means having two
methods with the same arguments, but
different implementation. One of them would
exist in the Parent class (Base Class) while
another will be in the derived class(Child
Class).
 An abstract class is a mix between an
interface and a class. It can define
functionality as well as interface (in the form
of abstract methods). Classes extending an
abstract class must implement all of the
abstract methods defined in the abstract
class.
 PHP :
 abstract class AbstractExample {
 public $name;
 public function doThis() {
 // do this
 }
 abstract public function doThat();
 }

Contenu connexe

Tendances

Tendances (20)

Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Object as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasObject as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younas
 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Introducing classes
Introducing classesIntroducing classes
Introducing classes
 
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
 
Object Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsObject Oriented Programming - Basic Concepts
Object Oriented Programming - Basic Concepts
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism
 
البرمجة الهدفية بلغة جافا - مفاهيم أساسية
البرمجة الهدفية بلغة جافا - مفاهيم أساسية البرمجة الهدفية بلغة جافا - مفاهيم أساسية
البرمجة الهدفية بلغة جافا - مفاهيم أساسية
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 
Friend Function
Friend FunctionFriend Function
Friend Function
 
Java
JavaJava
Java
 

En vedette

1.2 core programming [understand computer decision structures]
1.2 core programming [understand computer decision structures]1.2 core programming [understand computer decision structures]
1.2 core programming [understand computer decision structures]
tototo147
 
1.1 core programming [understand computer storage and data types]
1.1 core programming [understand computer storage and data types]1.1 core programming [understand computer storage and data types]
1.1 core programming [understand computer storage and data types]
tototo147
 

En vedette (13)

1.2 core programming [understand computer decision structures]
1.2 core programming [understand computer decision structures]1.2 core programming [understand computer decision structures]
1.2 core programming [understand computer decision structures]
 
1.1 core programming [understand computer storage and data types]
1.1 core programming [understand computer storage and data types]1.1 core programming [understand computer storage and data types]
1.1 core programming [understand computer storage and data types]
 
Sales Methodologies - A quick guide to boosting success - realSociable
Sales Methodologies - A quick guide to boosting success - realSociableSales Methodologies - A quick guide to boosting success - realSociable
Sales Methodologies - A quick guide to boosting success - realSociable
 
The beatles
The beatlesThe beatles
The beatles
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
 
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
 
Piling lica
Piling licaPiling lica
Piling lica
 
realSociable - Creating a need and changing sales flow
realSociable - Creating a need and changing sales flowrealSociable - Creating a need and changing sales flow
realSociable - Creating a need and changing sales flow
 
핑그래프(Fingra.ph) 모바일 게임 적용 사례
핑그래프(Fingra.ph) 모바일 게임 적용 사례핑그래프(Fingra.ph) 모바일 게임 적용 사례
핑그래프(Fingra.ph) 모바일 게임 적용 사례
 
realSociable Social Prospecting & Increasing Earned Value in Media
realSociable Social Prospecting & Increasing Earned Value in MediarealSociable Social Prospecting & Increasing Earned Value in Media
realSociable Social Prospecting & Increasing Earned Value in Media
 
핑그래프 리딤코드 적용법
핑그래프 리딤코드 적용법핑그래프 리딤코드 적용법
핑그래프 리딤코드 적용법
 
Engagement for a Modern Sales Team
Engagement for a Modern Sales TeamEngagement for a Modern Sales Team
Engagement for a Modern Sales Team
 
Final Presentation-KUHN
Final Presentation-KUHNFinal Presentation-KUHN
Final Presentation-KUHN
 

Similaire à Object oriented programming

oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
 
1207028 634528828886611250
1207028 6345288288866112501207028 634528828886611250
1207028 634528828886611250
Akhil Nama
 
com-213-unified-modelling-launguage-programming-theory.pdf
com-213-unified-modelling-launguage-programming-theory.pdfcom-213-unified-modelling-launguage-programming-theory.pdf
com-213-unified-modelling-launguage-programming-theory.pdf
AhmadInternetCafe
 

Similaire à Object oriented programming (20)

Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentBasic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Object oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptxObject oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptx
 
Python-Classes.pptx
Python-Classes.pptxPython-Classes.pptx
Python-Classes.pptx
 
Oops
OopsOops
Oops
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Learn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfLearn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdf
 
1207028 634528828886611250
1207028 6345288288866112501207028 634528828886611250
1207028 634528828886611250
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
com-213-unified-modelling-launguage-programming-theory.pdf
com-213-unified-modelling-launguage-programming-theory.pdfcom-213-unified-modelling-launguage-programming-theory.pdf
com-213-unified-modelling-launguage-programming-theory.pdf
 
chap11.ppt
chap11.pptchap11.ppt
chap11.ppt
 
2.oop concept
2.oop concept2.oop concept
2.oop concept
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Object oriented programming

  • 1. Lecture by Niko Adrianus Yuwono
  • 2.  Objects are key to understanding object- oriented programming.  Objects are like real-world objects like cat or car  Real-world objects share two characteristics: They all have state and behavior.  For example cats have state (name, color, breed, hungry) and behavior (meowing, fetching, wagging tail, playing).
  • 3.  Same as real-world object, object in programming also have that two characteristics : state (fields) and behavior (methods)  Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation — a fundamental principle of object-oriented programming.
  • 4.  In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other cats in existence, but all of them have same state and behaviour.  That’s why we use class to classify them.  Objects of the same kind are said to be members of the same class.  Let’s say there are Angora Cat, Persian Cat and Common Cat. All of them are members of Cat class and they have same basic state and behaviour.
  • 5.  Furthermore, if we want to make the classification bigger we can use Inheritance  Imagine a class with a very big scope let’s say we have a class named Animal that have fields legs, isHungry, isAlive, etc and methods eat, sleep, etc  The attribute in the class Animal can be inherited to their sub/child class
  • 6.  For example we’ve a class named cats that extends to animal class  That means animal class is the parent/super class of cats class  Cat class will get all the same fields and methods as animal class  However, you must take care to properly document the state and behavior that each superclass defines, since that code will not appear in the source file of each subclass.
  • 7.  This is a table of access member control that define which member of the class can be accessed Access Levels Modifier Class Package Subclass World public Y Y Y Y protected Y Y Y N no modifier Y Y N N private Y N N N
  • 8.  Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.
  • 9.  An interface is similar to a class except that it cannot contain code. An interface can define method names and arguments, but not the contents of the methods.  Any classes implementing an interface must implement all methods defined by the interface.
  • 10.  Objective-C  @interface Forwarder : Object  {  id someFields;  }  - (id) someMethod;  @end
  • 11.  PHP  interface InterfaceExample {  public function doSomething();  public function doEverything();  }
  • 12.  Java  interface Animal{  void eat(String what);  void sleep(int time);  void mate(String withWho); }
  • 13.  Method overloading deals with the notion of having two or more methods(functions) in the same class with the same name but different arguments.  While Method overriding means having two methods with the same arguments, but different implementation. One of them would exist in the Parent class (Base Class) while another will be in the derived class(Child Class).
  • 14.  An abstract class is a mix between an interface and a class. It can define functionality as well as interface (in the form of abstract methods). Classes extending an abstract class must implement all of the abstract methods defined in the abstract class.
  • 15.  PHP :  abstract class AbstractExample {  public $name;  public function doThis() {  // do this  }  abstract public function doThat();  }