SlideShare a Scribd company logo
Only oop
 Object oriented programming concept use to make
powerful, robust and secure programming instruction.
with any language reference there are
three very important object oriented programming
concepts.
1. Encapsulation and Data Abstraction.
2. Inheritance(Multiple and Multilevel).
3. Polymorphism.
 Real world programming.
 ability to simulate real-world event much more effectively
 Reusable of code.
 Information hiding.
 Better able to create GUI alications
 programmers are able to reach their goals faster
 Programmers are able to produce faster, more accurate
 Class is a blueprint of related data members and
methods.
 Classes are the fundamental construct behind object
oriented programming.
 It is a self contained, independent collection of
variables and functions, which work together to
perform one or more specific or related task.
 Variables within a class are called properties and
functions are called methods.
 Class always start with class name. After this we have to
write class name without parentheses. Inside curly braces
we have to define all programming logic. Eg:--

 class class_name
{
-----------
-------------
}
 Object is the instance of the class .
 Once a class has been defined, objects can be created from the
class with the new keyword.
 Class methods and properties can directly be accessed through
this object instance.
 Dot operator(->):- (->)symbol used to connect objects to their
properties or methods.
[NOTES:-We can’t access any property of the class without their object.]
 $VAR = new classname();
 new keyword is responsible to initialize a
object of the class.
 We call properties to the variables inside a class.
Properties can accept values like strings, integers, and
booleans (true/false values), like any other variable.
 Property could be public, private , protected
 class Car {
public $comp;
public $color = 'beige';
public $hasSunRoof = true;
}
 Methods are actions that can be performed
on objects. Object properties can be both
primitive values, other objects, and functions.
An object method is an object property
containing a function definition.
 Property could be public, private , protected
 <?php
 class a
 { function add($a,$b)
 { $add=$a+$b;
 echo "This is function add:--".$add;
 }
 function sub($x,$y)
 { $sub=$x-$y;
 echo "This is funcion sub--".$sub;
 }
 }
 $obj = new a;
 $obj->add(10,20);
 $obj->sub(50,20);
 ?>
 There are three levels of visibility exist,
ranging from most visible to least visible.
◦ Public
◦ Protected
◦ private
Controlling the Visibility of Properties and Methods
When working with classes, you can even restrict access to its
properties and methods using the visibility keywords for greater
control. There are three visibility keywords
•public — A public property or method can be accessed
anywhere, from within the class and outside. This is the default
visibility for all class members in PHP.
•protected — A protected property or method can only be
accessed from within the class
•ss itself or in child or inherited classes i.e. classes that extends
that class.
•private — A private property or method is accessible only from
within the class that defines it. Even child or inherited classes
cannot access private properties or methods.
<?php
class Example {
public $name="BCA II";
private $age;
}
$example = new Example;
echo $example -> name . "n";
echo $example -> age;
?>
 Constructor automatically call when object
will be initialize/found.
 PHP introduce a new functionality to define a
constructor i.e. __construct().
 By using this function we can define a
constructor and it is known as predefined
constructor.
 <?php
 class A
 {
 function testA() //function
 {
 echo "n This is test A";
 }

 function __construct() //constructor
 {
 echo "This is predefined constructor of class A";
 }
 //function A ()
 //{ echo "This is constructor a";
 // }
 }
 $obj = new A;
 $obj->testA();
 ?>
•__destruct() used to define destructor.
•It destroy the current object.
 <?php
 class A
 {
 function __construct()
 {
 echo "hello constuctor.....n ";
 }
 function __destruct() //Destructor
 {
 echo "ending up........stay at home";
 }
 }
 $obj = new A();
 unset($obj);
 ?>
 Constants are pieces of information stored in the
computer's memory which cannot be changed once
assigned.
 Class Constants are constants that are declared
within classes.
 The const keyword is used to declare a class
constant.
 The class constant should be declared inside the class
definition. No $ (dollar sign) used.
 <?php
 class Welcome
 {
 const GREET = 'Hello World';
 }
 Inside the class:
The self keyword and Scope Resolution
Operator (::) is used to access class constants
from the methods in a class.
public function greet()
{ echo self::GREET;
}

 Outside the class:
The class name and constant name is used to
access a class constant from outside a class.
echo Welcome::GREET;

<?php
class Welcome
{
const GREET = 'Hello World';
public function greet()
{ echo self::GREET;
}
}
$obj = new Welcome();
$obj -> greet();
echo "n";
echo Welcome::GREET;
echo $obj->GREET;
?>
 Static Methods and Properties can be
accessed without instantiating. (Without
creating objects)
 Static methods can be called directly without
needing an instance of the class (an object).
And, $this pseudo-variable is not available
inside static methods.
 The static keyword is used to declare static
methods.
class MyClass
{
public static function myStaticMethod()
{ echo "Hello!";
}
}
 Static methods can be accessed from outside
the class using the class name and Scope
Resolution Operator (::). (Only if the visibility
is public)
 MyClass::myStaticMethod();
<?php
class myexample
{
public static function getDomain()
{ return "Developer";
}
}
echo myexample::getDomain();
//$obj = new myexample;
//$obj->getDomain();
?>
 Static methods can be called from methods of
other classes in the same way. To do this
visibility of the static method should be
public.
<?php
class MyClass
{
public static function myStaticMethod()
{ echo "Hello";
}
}
class OtherClass
{ public function myMethod()
{MyClass::myStaticMethod();
}
}
$obj = new Otherclass;
$obj->myMethod();
?>
 $this can be used inside any method to refer
to the current object.
 $this is always a reference to the object on
which the method was invoked.
 By using inheritance concept we can inherit other class
properties with any specific class.
 In this process we have to establish relation between both
class using extends keyword.
 By using object of child class we can inherit parent class
properties.
 It has two types.
◦ Multilevel inheritance
◦ Multiple inheritance (Not available in PHP)
[multiple inheritance feature is only available in c++ prog.
language And multilevel inheritance feature is available in
programming languages like PHP, Java etc.]21
 Multiple Inheritance : we can inherit more
than one class in the same class.
 Multi-Level Inheritance: where one class can
inherit only one base class and the derived
class can become base class of some other
class.
 In Multiple inheritance like this:
 Base Class
_________________
/ | 
Class1 Class2 Class3
Multilevel Inheritance:
Base Class
||
Class1
||
Class2
 get_class():- this function returns the name of
the class from which an object was
instantiated.
 get_parent_class():- it returns the name of its
parent.
 parent():- keyword parent provides an easy
shortcut to refer to the current class parent.
<?php
class a{
public $age;
function __construct(){
echo "creating a new
".get_class($this)."--- class";
}
function setAge($age){
$this->age=$age;
}
function getAge(){
return $this->age;
}
}
class b extends a
{
public $name;
function __construct(){
parent::__construct();
}
function setName($name){
$this->name = $name;
}
function getName(){
return $this->name;
}
}
$obj = new b;
$obj->setAge(25);
$obj->setName("Kamlesh Dutt");
echo $obj->getName().'is now
'.$obj->getAge().' years old';
?>
 An abstract class is a incomplete class which has
abstract methods. The abstract methods are
those which are only declared but not defined.
 The abstract class is always inherited and this is
the responsibility of sub class to define all the
abstract method of its super class. If the sub
class does not define any single method of
abstract class, then it is also treated as abstract
class.
 It is not allowed to create an instance of a class
that has been defined as abstract.
 Abstract classes allow you to provide default
functionality for the subclasses. Common
knowledge at this point. Why is this
extremely important though? If you plan on
updating this base class throughout the life
of your program, it is best to allow that base
class to be an abstract class. Why? Because
you can make a change to it and all of the
inheriting classes will now have this new
functionality.
 If the base class will be changing often and
an interface was used instead of an abstract
class, we are going to run into problems.
Once an interface is changed, any class that
implements that will be broken.
<?php
abstract class AbstractClass
{
// Force Extending class to
define this method
abstract protected function
getValue();
abstract protected function
prefixValue($prefix);
// Common method
public function printOut()
{
print $this->getValue() .
"n";
}
}
class ConcreteClass1 extends
AbstractClass
{
protected function getValue() {
return “Parent Class”;
}
public function
prefixValue($prefix) {
return "{$prefix}calling parent";
}
}
$class1 = new ConcreteClass1;
$class1->printOut();
echo $class1->prefixValue(‘Child') .
“n";
?>
//Parent Class
Child calling parent
 Object interfaces allow you to create code
which specifies which methods a class must
implement, without having to define how
these methods are handled.
 Interfaces are defined using the interface
keyword, in the same way as a standard class,
but without any of the methods having their
contents defined.
 All methods declared in an interface must be
public, this is the nature of an interface.
 implements
To implement an interface, the implements
operator is used. All methods in the interface
must be implemented within a class; failure to do
so will result in a fatal error. Classes may
implement more than one interface if desired by
separating each interface with a comma.
 Note:
A class cannot implement two interfaces that
share function names, since it would cause
ambiguity.
 Interfaces provides a form of multiple
inheritance . An abstract class can extend one
other class.
 A class may implements severeal interface.
But incase of abstract class, class may extend
only one single abstract class.
 Interfaces are slow as it requires extra
indirection to find corresponding method in
the actual class where abstract class are fast.
 Php 5 introduces the final keyword, which
prevents child classes from overriding a
method by prefixing the definition with final.
If the class itself is being defined final then it
can not be extended.
 Properties can’t be declared final, only classes
and methods may be declared as final.
Only oop
 It is used to test if an object is an instance of
a particular class. This operator returns true if
the object instance has the named class
anywhere in its parent tree.
 <?php
 class a
 {
 }
 class Mammal extends a
 {

 }
 class Human extends Mammal
 {

 }
 $obj = new Human;
 echo ($obj instanceof a ?'true':'false';
 ?>

More Related Content

PPTX
Object oreinted php | OOPs
PPT
PHP - Introduction to Object Oriented Programming with PHP
PPT
Introduction to OOP with PHP
PDF
09 Object Oriented Programming in PHP #burningkeyboards
PPT
Oops concepts in php
PDF
Demystifying oop
PPTX
Object oriented programming in php 5
Object oreinted php | OOPs
PHP - Introduction to Object Oriented Programming with PHP
Introduction to OOP with PHP
09 Object Oriented Programming in PHP #burningkeyboards
Oops concepts in php
Demystifying oop
Object oriented programming in php 5

What's hot (20)

PPTX
Python advance
PPTX
Object oriented programming in php
PPT
Class 7 - PHP Object Oriented Programming
PPT
PHP- Introduction to Object Oriented PHP
PPTX
Php oop presentation
PPT
Oops in PHP
PDF
Object Oriented Programming with PHP 5 - More OOP
PPT
Php Oop
PDF
OOP in PHP
PPTX
Classes, objects in JAVA
PPS
Introduction to class in java
PDF
Object Oriented Programming in PHP
PPTX
Introduction to OOP(in java) BY Govind Singh
ZIP
Object Oriented PHP5
PDF
Demystifying Object-Oriented Programming - PHP[tek] 2017
PPTX
Ppt on this and super keyword
PPTX
Inheritance in Java
PPTX
Object oriented programming with python
PPT
Java: Inheritance
Python advance
Object oriented programming in php
Class 7 - PHP Object Oriented Programming
PHP- Introduction to Object Oriented PHP
Php oop presentation
Oops in PHP
Object Oriented Programming with PHP 5 - More OOP
Php Oop
OOP in PHP
Classes, objects in JAVA
Introduction to class in java
Object Oriented Programming in PHP
Introduction to OOP(in java) BY Govind Singh
Object Oriented PHP5
Demystifying Object-Oriented Programming - PHP[tek] 2017
Ppt on this and super keyword
Inheritance in Java
Object oriented programming with python
Java: Inheritance
Ad

Similar to Only oop (20)

PDF
Object Oriented Programming in PHP
PPT
Advanced php
PDF
Object_oriented_programming_OOP_with_PHP.pdf
PPTX
Ch8(oop)
PPTX
Lecture-10_PHP-OOP.pptx
PDF
OOP in PHP
PPTX
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
PPTX
UNIT III (8).pptx
PPTX
UNIT III (8).pptx
PPT
Synapseindia object oriented programming in php
PDF
Object Oriented PHP - PART-1
PPTX
Php oop (1)
PDF
Demystifying Object-Oriented Programming #phpbnl18
PPTX
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
PPTX
Lecture 17 - PHP-Object-Orientation.pptx
PPT
Php object orientation and classes
PPT
UNIT-IV WT web technology for 1st year cs
PPTX
OOP in PHP.pptx
PPTX
OOP in PHP
PPTX
Oopsinphp
Object Oriented Programming in PHP
Advanced php
Object_oriented_programming_OOP_with_PHP.pdf
Ch8(oop)
Lecture-10_PHP-OOP.pptx
OOP in PHP
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
UNIT III (8).pptx
UNIT III (8).pptx
Synapseindia object oriented programming in php
Object Oriented PHP - PART-1
Php oop (1)
Demystifying Object-Oriented Programming #phpbnl18
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
Lecture 17 - PHP-Object-Orientation.pptx
Php object orientation and classes
UNIT-IV WT web technology for 1st year cs
OOP in PHP.pptx
OOP in PHP
Oopsinphp
Ad

Recently uploaded (20)

PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
RMMM.pdf make it easy to upload and study
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Institutional Correction lecture only . . .
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Cell Types and Its function , kingdom of life
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Business Ethics Teaching Materials for college
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharma ospi slides which help in ospi learning
RMMM.pdf make it easy to upload and study
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
TR - Agricultural Crops Production NC III.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Institutional Correction lecture only . . .
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial disease of the cardiovascular and lymphatic systems
Module 4: Burden of Disease Tutorial Slides S2 2025
Cell Types and Its function , kingdom of life
PPH.pptx obstetrics and gynecology in nursing
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Microbial diseases, their pathogenesis and prophylaxis
Business Ethics Teaching Materials for college
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...

Only oop

  • 2.  Object oriented programming concept use to make powerful, robust and secure programming instruction. with any language reference there are three very important object oriented programming concepts. 1. Encapsulation and Data Abstraction. 2. Inheritance(Multiple and Multilevel). 3. Polymorphism.
  • 3.  Real world programming.  ability to simulate real-world event much more effectively  Reusable of code.  Information hiding.  Better able to create GUI alications  programmers are able to reach their goals faster  Programmers are able to produce faster, more accurate
  • 4.  Class is a blueprint of related data members and methods.  Classes are the fundamental construct behind object oriented programming.  It is a self contained, independent collection of variables and functions, which work together to perform one or more specific or related task.  Variables within a class are called properties and functions are called methods.
  • 5.  Class always start with class name. After this we have to write class name without parentheses. Inside curly braces we have to define all programming logic. Eg:--   class class_name { ----------- ------------- }
  • 6.  Object is the instance of the class .  Once a class has been defined, objects can be created from the class with the new keyword.  Class methods and properties can directly be accessed through this object instance.  Dot operator(->):- (->)symbol used to connect objects to their properties or methods. [NOTES:-We can’t access any property of the class without their object.]
  • 7.  $VAR = new classname();  new keyword is responsible to initialize a object of the class.
  • 8.  We call properties to the variables inside a class. Properties can accept values like strings, integers, and booleans (true/false values), like any other variable.  Property could be public, private , protected  class Car { public $comp; public $color = 'beige'; public $hasSunRoof = true; }
  • 9.  Methods are actions that can be performed on objects. Object properties can be both primitive values, other objects, and functions. An object method is an object property containing a function definition.  Property could be public, private , protected
  • 10.  <?php  class a  { function add($a,$b)  { $add=$a+$b;  echo "This is function add:--".$add;  }  function sub($x,$y)  { $sub=$x-$y;  echo "This is funcion sub--".$sub;  }  }  $obj = new a;  $obj->add(10,20);  $obj->sub(50,20);  ?>
  • 11.  There are three levels of visibility exist, ranging from most visible to least visible. ◦ Public ◦ Protected ◦ private
  • 12. Controlling the Visibility of Properties and Methods When working with classes, you can even restrict access to its properties and methods using the visibility keywords for greater control. There are three visibility keywords •public — A public property or method can be accessed anywhere, from within the class and outside. This is the default visibility for all class members in PHP. •protected — A protected property or method can only be accessed from within the class •ss itself or in child or inherited classes i.e. classes that extends that class. •private — A private property or method is accessible only from within the class that defines it. Even child or inherited classes cannot access private properties or methods.
  • 13. <?php class Example { public $name="BCA II"; private $age; } $example = new Example; echo $example -> name . "n"; echo $example -> age; ?>
  • 14.  Constructor automatically call when object will be initialize/found.  PHP introduce a new functionality to define a constructor i.e. __construct().  By using this function we can define a constructor and it is known as predefined constructor.
  • 15.  <?php  class A  {  function testA() //function  {  echo "n This is test A";  }   function __construct() //constructor  {  echo "This is predefined constructor of class A";  }  //function A ()  //{ echo "This is constructor a";  // }  }  $obj = new A;  $obj->testA();  ?>
  • 16. •__destruct() used to define destructor. •It destroy the current object.
  • 17.  <?php  class A  {  function __construct()  {  echo "hello constuctor.....n ";  }  function __destruct() //Destructor  {  echo "ending up........stay at home";  }  }  $obj = new A();  unset($obj);  ?>
  • 18.  Constants are pieces of information stored in the computer's memory which cannot be changed once assigned.  Class Constants are constants that are declared within classes.  The const keyword is used to declare a class constant.  The class constant should be declared inside the class definition. No $ (dollar sign) used.  <?php  class Welcome  {  const GREET = 'Hello World';  }
  • 19.  Inside the class: The self keyword and Scope Resolution Operator (::) is used to access class constants from the methods in a class. public function greet() { echo self::GREET; } 
  • 20.  Outside the class: The class name and constant name is used to access a class constant from outside a class. echo Welcome::GREET; 
  • 21. <?php class Welcome { const GREET = 'Hello World'; public function greet() { echo self::GREET; } } $obj = new Welcome(); $obj -> greet(); echo "n"; echo Welcome::GREET; echo $obj->GREET; ?>
  • 22.  Static Methods and Properties can be accessed without instantiating. (Without creating objects)  Static methods can be called directly without needing an instance of the class (an object). And, $this pseudo-variable is not available inside static methods.  The static keyword is used to declare static methods.
  • 23. class MyClass { public static function myStaticMethod() { echo "Hello!"; } }
  • 24.  Static methods can be accessed from outside the class using the class name and Scope Resolution Operator (::). (Only if the visibility is public)  MyClass::myStaticMethod();
  • 25. <?php class myexample { public static function getDomain() { return "Developer"; } } echo myexample::getDomain(); //$obj = new myexample; //$obj->getDomain(); ?>
  • 26.  Static methods can be called from methods of other classes in the same way. To do this visibility of the static method should be public.
  • 27. <?php class MyClass { public static function myStaticMethod() { echo "Hello"; } } class OtherClass { public function myMethod() {MyClass::myStaticMethod(); } } $obj = new Otherclass; $obj->myMethod(); ?>
  • 28.  $this can be used inside any method to refer to the current object.  $this is always a reference to the object on which the method was invoked.
  • 29.  By using inheritance concept we can inherit other class properties with any specific class.  In this process we have to establish relation between both class using extends keyword.  By using object of child class we can inherit parent class properties.  It has two types. ◦ Multilevel inheritance ◦ Multiple inheritance (Not available in PHP) [multiple inheritance feature is only available in c++ prog. language And multilevel inheritance feature is available in programming languages like PHP, Java etc.]21
  • 30.  Multiple Inheritance : we can inherit more than one class in the same class.  Multi-Level Inheritance: where one class can inherit only one base class and the derived class can become base class of some other class.
  • 31.  In Multiple inheritance like this:  Base Class _________________ / | Class1 Class2 Class3 Multilevel Inheritance: Base Class || Class1 || Class2
  • 32.  get_class():- this function returns the name of the class from which an object was instantiated.  get_parent_class():- it returns the name of its parent.  parent():- keyword parent provides an easy shortcut to refer to the current class parent.
  • 33. <?php class a{ public $age; function __construct(){ echo "creating a new ".get_class($this)."--- class"; } function setAge($age){ $this->age=$age; } function getAge(){ return $this->age; } } class b extends a { public $name; function __construct(){ parent::__construct(); } function setName($name){ $this->name = $name; } function getName(){ return $this->name; } } $obj = new b; $obj->setAge(25); $obj->setName("Kamlesh Dutt"); echo $obj->getName().'is now '.$obj->getAge().' years old'; ?>
  • 34.  An abstract class is a incomplete class which has abstract methods. The abstract methods are those which are only declared but not defined.  The abstract class is always inherited and this is the responsibility of sub class to define all the abstract method of its super class. If the sub class does not define any single method of abstract class, then it is also treated as abstract class.  It is not allowed to create an instance of a class that has been defined as abstract.
  • 35.  Abstract classes allow you to provide default functionality for the subclasses. Common knowledge at this point. Why is this extremely important though? If you plan on updating this base class throughout the life of your program, it is best to allow that base class to be an abstract class. Why? Because you can make a change to it and all of the inheriting classes will now have this new functionality.
  • 36.  If the base class will be changing often and an interface was used instead of an abstract class, we are going to run into problems. Once an interface is changed, any class that implements that will be broken.
  • 37. <?php abstract class AbstractClass { // Force Extending class to define this method abstract protected function getValue(); abstract protected function prefixValue($prefix); // Common method public function printOut() { print $this->getValue() . "n"; } } class ConcreteClass1 extends AbstractClass { protected function getValue() { return “Parent Class”; } public function prefixValue($prefix) { return "{$prefix}calling parent"; } } $class1 = new ConcreteClass1; $class1->printOut(); echo $class1->prefixValue(‘Child') . “n"; ?> //Parent Class Child calling parent
  • 38.  Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled.  Interfaces are defined using the interface keyword, in the same way as a standard class, but without any of the methods having their contents defined.  All methods declared in an interface must be public, this is the nature of an interface.
  • 39.  implements To implement an interface, the implements operator is used. All methods in the interface must be implemented within a class; failure to do so will result in a fatal error. Classes may implement more than one interface if desired by separating each interface with a comma.  Note: A class cannot implement two interfaces that share function names, since it would cause ambiguity.
  • 40.  Interfaces provides a form of multiple inheritance . An abstract class can extend one other class.  A class may implements severeal interface. But incase of abstract class, class may extend only one single abstract class.  Interfaces are slow as it requires extra indirection to find corresponding method in the actual class where abstract class are fast.
  • 41.  Php 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it can not be extended.  Properties can’t be declared final, only classes and methods may be declared as final.
  • 43.  It is used to test if an object is an instance of a particular class. This operator returns true if the object instance has the named class anywhere in its parent tree.
  • 44.  <?php  class a  {  }  class Mammal extends a  {   }  class Human extends Mammal  {   }  $obj = new Human;  echo ($obj instanceof a ?'true':'false';  ?>