SlideShare a Scribd company logo
OOPS CONCEPTS
Rajishma T
rajishmatnair@gmail.com
www.facebook.com/ Rajishma T
Nair
twitter.com/username
in.linkedin.com/in/profilename
9020217968
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
CLASS
 A class is an expanded concept of a data,it
can hold both data and functions.
A class is the blueprint for your object.
A class, for example, is like a blueprint for a
house. It defines the shape of the house on
paper, with relationships between the
different parts of the house clearly defined
and planned out, even though the house
doesn’t exist.
visibility
The visibility of class members, (properties,
methods), relates to how that member may be
manipulated within, or from outside the class.
 private:private members are accessible only in
the class itself.
Public:public members are accessible outside the
class(anywhere).
Protected:protected members are accessible in the
same package,and the subclasses of the class and
inside the class.
OOPS CHARACTERESTICS
 data encapsulation.
 inheritance.
Polymorphism.
Data abstraction.
ENCAPSULATION
The wrapping up of a data and functions into a single
unit(which is called class).
Encapsulation means that some or all of an objects
internal structure is hidden from the outside world.
Hidden information may only be accessed through
the object’s public interface.
example
<?php
class MyClass
{
public $prop1 = "I'm a class property!";
public function setProperty($newval)
{
$this->prop1 = $newval;
}
public function getProperty()
{
return $this->prop1 . "<br />";
}
}
$obj = new MyClass;
echo $obj->getProperty(); // Get the property value
$obj->setProperty("I'm a new property value!"); // Set a new one
echo $obj->getProperty(); // Read it out again to show the change
?>
Output
• http://localhost/phpWorkspace/oops.php/class.php
INHERITANCE
• When you want to create a new class and there is
already a class that includes some of the code
that you want, you can derive your new class
from the existing class.
• A class that is derived from another class is called
a subclass (also a derived class, extended class, or
child class).
• The class from which the subclass is derived is
called a superclass (also a base class or a parent
class).
TYPES OF INHERITANCE
• Single Inheritance
• Hierarchical Inheritance
• Multi Level Inheritance
• Hybrid Inheritance
• Multiple Inheritance
SINGLE INHERITANCE
• when a single derived class is created from a
single base class then the inheritance is called
as single inheritance.
HIERARCHICAL INHERITANCE
• when more than one derived class are created
from a single base class, then that inheritance
is called as hierarchical inheritance.
MULTILEVEL INHERITANCE
• when a derived class is created from another
derived class, then that inheritance is called as
multi level inheritance.
HYBRID INHERITANCE
• Any combination of single, hierarchical and
multi level inheritances is called as hybrid
inheritance.
MULTIPLE INHERITANCE
• when a derived class is created from more
than one base class then that inheritance is
called as multiple inheritance.
Single inheritance
<?php
class parentclass
{
public function sum($a,$b)
{
echo $a+$b;
}
}
class childclass extends parentclass
{
public function diff($a,$b)
{
echo $a-$b;
}
}
$obj1=new childclass();
$obj1->sum(4,5);
echo "<br />";
echo "<br />";
$obj1->diff(8,3);
?>
Output:
http://localhost/phpWorkspace/oops.php/inheritance1.php
Hierarchical inheritance
<?php
class a
{
public function function_a()
{
echo "classA";
}
}
class b extends a
{
public function function_b()
{
echo "classB";
}
}
class c extends a
{
public function function_c()
{
echo "classC";
}
}
echo c::function_c();
echo "<br />";
echo c::function_a();
echo “<br />
echo b::function_a();
?>
• Output
http://localhost/phpWorkspace/oops.php/hie
rarchicalinheritance.php
Multilevel inheritance
<?php
class a
{
public function function_a()
{
echo 'classa';
}
}
class b extends a
{
public function function_b()
{
echo 'classb';
}
}
class c extends b
{
public function function_c()
{
echo 'classc';
}
}
echo c::function_c();
echo "<br />";
eCho c::function_b();
echo "<br />";
echo c::function_a();
?>
OUTPUT
http://localhost/phpWorkspace/oops.php/multilevel.php
POLYMORPHISM
• Poly means many,morphism means forms.
• Polymorphism feature enables classes to
provide different implementation of methods
having the same name.
• Two types of polymorphism
Compile time(overloading)
Runtime(overriding)
OVERRIDING
• When we create a function in a derived class
with the same signature (in other words a
function has the same name, the same
number of arguments and the same type of
arguments) as a function in its parent class
then it is called method overriding.
example
<?php
class Shap
{
function draw(){}
}
class Circle extends Shap
{
function draw()
{
print "Circle has been drawn.</br>";
}
}
class Triangle extends Shap
{
function draw()
{
print "Triangle has been drawn.</br>";
}
}
class Ellipse extends Shap
{
function draw()
{
print "Ellipse has been drawn.";
}
}
}
$Val=array(2);
$Val[0]=new Circle();
$Val[1]=new Triangle();
$Val[2]=new Ellipse();
for($i=0;$i<3;$i++)
{
$Val[$i]->draw();
}
?>
• Output
http://localhost/phpWorkspace/oops.php/overriding.php
OVERLOADING
• Method overloading means having two or
more methods with the same name but
different signatures in the same scope. These
two methods may exist in the same class or
another one in base class and another in
derived class.
Example<?php
function findSum()
{
$sum = 0;
foreach (func_get_args() as $arg)
{
$sum += $arg;
}
return $sum;
}
echo findSum(1, 2), '<br />';
echo findSum(10, 2, 100), '<br />';
echo findSum(10, 22, 0.5, 0.75, 12.50), '<br />';
?>
Output:
http://localhost/phpWorkspace/oops.php/overloading.php
DATA ABSTRACTION
• Any representation of data in which the implementation
details are hidden (abstracted).
• Data abstraction refers to, providing only essential
information to the outside word and hiding their background
details ie. to represent the needed information in program
without presenting the details
• They provide sufficient public methods to the outside world
to play with the functionality of the object and to manipulate
object data ie. state without actually knowing how class has
been implemented internally.
ABSTRACT CLASS
• An abstract class is one that cannot be
instantiated, only inherited. You declare an
abstract class with the keyword abstract
• When inheriting from an abstract class, all
methods marked abstract in the parent's class
declaration must be defined by the child;
<?php
abstract class One
{
abstract function disp();
}
class Two extends One
{
public function disp()
{
echo "Inside the child class<br/>";
}
}
class Three extends One
{
public function disp()
{
echo "Inside the child class 2<br/>";}
}
$two=new Two();
echo "<b>Calling from the child class Two:</b><br/>";
$two->disp();
echo "<b>Calling from the child class Three:</b><br/>";
$three=new Three();
$three->disp();
?>
Output
http://localhost/phpWorkspace/oops.php/abstractclass.php
INTERFACE
• Interface is a special class used like a template
for a group of classes with similar functions,
which must define a certain structure of
methods.
• It can contain constants and method
declarations, but not method bodies.
<?php
interface testdrive
{
function drive();
function stop();
}
class vehicle implements testdrive
{
public function __construct()
{
echo 'About this Vehicle.<br />';
}
public function drive()
{
echo 'VRRROOOOOOM!!!';
}
public function stop()
{
echo 'SSSCCRRREEEEEECCHH!!!<br />';
}
}
$object = new vehicle;
$object->drive();
$object->stop();
?>
Output
http://localhost/phpWorkspace/oops.php/interf
ace.php
ABSTRACT CLASS INTERFACE
The Abstract methods can declare with
Access modifiers like public, internal,
protected. When implementing in
subclass these methods must be defined
with the same (or a less restricted)
visibility.
All methods declared in an interface must
be public.
Abstract class can contain variables and
concrete methods.
Interfaces cannot contain variables and
concrete methods except constants.
A class can Inherit only one Abstract class
and Multiple inheritance is not possible
for Abstract class.
A class can implement many interfaces
and Multiple interface inheritance is
possible.
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com

More Related Content

What's hot

CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
Rob LaPlaca
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
Md.Al-imran Roton
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
Maruf Abdullah (Rion)
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Polymorphism in oop
Polymorphism in oopPolymorphism in oop
Polymorphism in oop
MustafaIbrahimy
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
Prof. Dr. K. Adisesha
 
Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++
vivekkumar2938
 
Javascript
JavascriptJavascript
Javascript
Manav Prasad
 
Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
AakankshaR
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Iqra khalil
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Css selectors
Css selectorsCss selectors
Css selectors
Parth Trivedi
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
Nahian Ahmed
 

What's hot (20)

CSS
CSSCSS
CSS
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Polymorphism in oop
Polymorphism in oopPolymorphism in oop
Polymorphism in oop
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++
 
Javascript
JavascriptJavascript
Javascript
 
Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Event handling
Event handlingEvent handling
Event handling
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 

Viewers also liked

What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
Simon Jones
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
Mindfire Solutions
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
Muhammad Younis
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5
Sayed Ahmed
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
fakhrul hasan
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
Rick Ogden
 
Font
FontFont
Php variables (english)
Php variables (english)Php variables (english)
Php variables (english)
Mahmoud Masih Tehrani
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
SHIVANI SONI
 
Execute MySQL query using command prompt
Execute MySQL query using command promptExecute MySQL query using command prompt
Execute MySQL query using command promptIkhwan Krisnadi
 
PHP
PHPPHP
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
Mohamed Loey
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In PhpHarit Kothari
 
PHP variables
PHP  variablesPHP  variables
PHP variables
Siddique Ibrahim
 

Viewers also liked (20)

What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5
 
Modern PHP
Modern PHPModern PHP
Modern PHP
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
 
Font
FontFont
Font
 
Php variables (english)
Php variables (english)Php variables (english)
Php variables (english)
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
Htmltag.ppt
Htmltag.pptHtmltag.ppt
Htmltag.ppt
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Execute MySQL query using command prompt
Execute MySQL query using command promptExecute MySQL query using command prompt
Execute MySQL query using command prompt
 
OOPS Characteristics
OOPS CharacteristicsOOPS Characteristics
OOPS Characteristics
 
PHP
PHPPHP
PHP
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 

Similar to OOPS Characteristics (With Examples in PHP)

Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
PRIYACHAURASIYA25
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
NithyaN19
 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptx
rayanbabur
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
Abdii Rashid
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
Kalai Selvi
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
RAJ KUMAR
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
mcollison
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
DevaKumari Vijay
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
KartikKapgate
 
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
Hari kiran G
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritance
teach4uin
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritance
teach4uin
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
LadallaRajKumar
 
Inheritance
InheritanceInheritance
Inheritance
Munsif Ullah
 
29csharp
29csharp29csharp
29csharp
Sireesh K
 
29c
29c29c

Similar to OOPS Characteristics (With Examples in PHP) (20)

Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptx
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritance
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritance
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 
Inheritance
InheritanceInheritance
Inheritance
 
29csharp
29csharp29csharp
29csharp
 
29c
29c29c
29c
 

More from baabtra.com - No. 1 supplier of quality freshers

Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Php database connectivity
Php database connectivityPhp database connectivity
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Blue brain
Blue brainBlue brain
5g
5g5g
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Recently uploaded

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 

Recently uploaded (20)

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

OOPS Characteristics (With Examples in PHP)

  • 1.
  • 2. OOPS CONCEPTS Rajishma T rajishmatnair@gmail.com www.facebook.com/ Rajishma T Nair twitter.com/username in.linkedin.com/in/profilename 9020217968
  • 3. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 4. CLASS  A class is an expanded concept of a data,it can hold both data and functions. A class is the blueprint for your object. A class, for example, is like a blueprint for a house. It defines the shape of the house on paper, with relationships between the different parts of the house clearly defined and planned out, even though the house doesn’t exist.
  • 5. visibility The visibility of class members, (properties, methods), relates to how that member may be manipulated within, or from outside the class.  private:private members are accessible only in the class itself. Public:public members are accessible outside the class(anywhere). Protected:protected members are accessible in the same package,and the subclasses of the class and inside the class.
  • 6. OOPS CHARACTERESTICS  data encapsulation.  inheritance. Polymorphism. Data abstraction.
  • 7. ENCAPSULATION The wrapping up of a data and functions into a single unit(which is called class). Encapsulation means that some or all of an objects internal structure is hidden from the outside world. Hidden information may only be accessed through the object’s public interface.
  • 8. example <?php class MyClass { public $prop1 = "I'm a class property!"; public function setProperty($newval) { $this->prop1 = $newval; } public function getProperty() { return $this->prop1 . "<br />"; } } $obj = new MyClass; echo $obj->getProperty(); // Get the property value $obj->setProperty("I'm a new property value!"); // Set a new one echo $obj->getProperty(); // Read it out again to show the change ?> Output • http://localhost/phpWorkspace/oops.php/class.php
  • 9. INHERITANCE • When you want to create a new class and there is already a class that includes some of the code that you want, you can derive your new class from the existing class. • A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). • The class from which the subclass is derived is called a superclass (also a base class or a parent class).
  • 10. TYPES OF INHERITANCE • Single Inheritance • Hierarchical Inheritance • Multi Level Inheritance • Hybrid Inheritance • Multiple Inheritance
  • 11. SINGLE INHERITANCE • when a single derived class is created from a single base class then the inheritance is called as single inheritance.
  • 12. HIERARCHICAL INHERITANCE • when more than one derived class are created from a single base class, then that inheritance is called as hierarchical inheritance.
  • 13. MULTILEVEL INHERITANCE • when a derived class is created from another derived class, then that inheritance is called as multi level inheritance.
  • 14. HYBRID INHERITANCE • Any combination of single, hierarchical and multi level inheritances is called as hybrid inheritance.
  • 15. MULTIPLE INHERITANCE • when a derived class is created from more than one base class then that inheritance is called as multiple inheritance.
  • 16. Single inheritance <?php class parentclass { public function sum($a,$b) { echo $a+$b; } } class childclass extends parentclass { public function diff($a,$b) { echo $a-$b; } } $obj1=new childclass(); $obj1->sum(4,5); echo "<br />"; echo "<br />"; $obj1->diff(8,3); ?> Output: http://localhost/phpWorkspace/oops.php/inheritance1.php
  • 17. Hierarchical inheritance <?php class a { public function function_a() { echo "classA"; } } class b extends a { public function function_b() { echo "classB"; } } class c extends a { public function function_c() { echo "classC"; } }
  • 18. echo c::function_c(); echo "<br />"; echo c::function_a(); echo “<br /> echo b::function_a(); ?> • Output http://localhost/phpWorkspace/oops.php/hie rarchicalinheritance.php
  • 19. Multilevel inheritance <?php class a { public function function_a() { echo 'classa'; } } class b extends a { public function function_b() { echo 'classb'; } } class c extends b { public function function_c() { echo 'classc'; } }
  • 20. echo c::function_c(); echo "<br />"; eCho c::function_b(); echo "<br />"; echo c::function_a(); ?> OUTPUT http://localhost/phpWorkspace/oops.php/multilevel.php
  • 21. POLYMORPHISM • Poly means many,morphism means forms. • Polymorphism feature enables classes to provide different implementation of methods having the same name. • Two types of polymorphism Compile time(overloading) Runtime(overriding)
  • 22. OVERRIDING • When we create a function in a derived class with the same signature (in other words a function has the same name, the same number of arguments and the same type of arguments) as a function in its parent class then it is called method overriding.
  • 23. example <?php class Shap { function draw(){} } class Circle extends Shap { function draw() { print "Circle has been drawn.</br>"; } } class Triangle extends Shap { function draw() { print "Triangle has been drawn.</br>"; } } class Ellipse extends Shap { function draw() { print "Ellipse has been drawn."; } } }
  • 24. $Val=array(2); $Val[0]=new Circle(); $Val[1]=new Triangle(); $Val[2]=new Ellipse(); for($i=0;$i<3;$i++) { $Val[$i]->draw(); } ?> • Output http://localhost/phpWorkspace/oops.php/overriding.php
  • 25. OVERLOADING • Method overloading means having two or more methods with the same name but different signatures in the same scope. These two methods may exist in the same class or another one in base class and another in derived class.
  • 26. Example<?php function findSum() { $sum = 0; foreach (func_get_args() as $arg) { $sum += $arg; } return $sum; } echo findSum(1, 2), '<br />'; echo findSum(10, 2, 100), '<br />'; echo findSum(10, 22, 0.5, 0.75, 12.50), '<br />'; ?> Output: http://localhost/phpWorkspace/oops.php/overloading.php
  • 27. DATA ABSTRACTION • Any representation of data in which the implementation details are hidden (abstracted). • Data abstraction refers to, providing only essential information to the outside word and hiding their background details ie. to represent the needed information in program without presenting the details • They provide sufficient public methods to the outside world to play with the functionality of the object and to manipulate object data ie. state without actually knowing how class has been implemented internally.
  • 28. ABSTRACT CLASS • An abstract class is one that cannot be instantiated, only inherited. You declare an abstract class with the keyword abstract • When inheriting from an abstract class, all methods marked abstract in the parent's class declaration must be defined by the child;
  • 29. <?php abstract class One { abstract function disp(); } class Two extends One { public function disp() { echo "Inside the child class<br/>"; } } class Three extends One { public function disp() { echo "Inside the child class 2<br/>";} }
  • 30. $two=new Two(); echo "<b>Calling from the child class Two:</b><br/>"; $two->disp(); echo "<b>Calling from the child class Three:</b><br/>"; $three=new Three(); $three->disp(); ?> Output http://localhost/phpWorkspace/oops.php/abstractclass.php
  • 31. INTERFACE • Interface is a special class used like a template for a group of classes with similar functions, which must define a certain structure of methods. • It can contain constants and method declarations, but not method bodies.
  • 32. <?php interface testdrive { function drive(); function stop(); } class vehicle implements testdrive { public function __construct() { echo 'About this Vehicle.<br />'; } public function drive() { echo 'VRRROOOOOOM!!!'; } public function stop() { echo 'SSSCCRRREEEEEECCHH!!!<br />'; } }
  • 33. $object = new vehicle; $object->drive(); $object->stop(); ?> Output http://localhost/phpWorkspace/oops.php/interf ace.php
  • 34. ABSTRACT CLASS INTERFACE The Abstract methods can declare with Access modifiers like public, internal, protected. When implementing in subclass these methods must be defined with the same (or a less restricted) visibility. All methods declared in an interface must be public. Abstract class can contain variables and concrete methods. Interfaces cannot contain variables and concrete methods except constants. A class can Inherit only one Abstract class and Multiple inheritance is not possible for Abstract class. A class can implement many interfaces and Multiple interface inheritance is possible.
  • 35. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 36. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com