1. Question:What are constructor and destructor? 

    Answer
    Constructor: A constructor is defined as a block of code that automatically executes at the time of object instantiation. Constructors can accept parameters, call class methods or  other functions.PHP recognizes constructor by the  name__construct.  The general  Syntax→
            function__construct([argument1,argument2,….,argumentN]){
                //Class initialization code  
            }
    Destructor:
     We can use destructors to modify the object destruction process.Derstructors are  created like any other method but must be titled    __destruct().   Syntax→    
    function__destruct().






    1. Report
  2. Question:What is object cloning?

     

    Answer
    To remedy the problems with copying ,PHP offers an explicit means for cloning an object.We clone an object by prefacing it with the clone keyword, like so:
                  destinationObject = clone targetObject;






    1. Report
  3. Question:What type of inheritance that PHP supports?
                

    Answer
    The object-oriented development methodology places great stock in the concept of inheritance.This strategy promotes code reusability. PHP generally supports single type of inheritance.






    1. Report
  4. Question:What are the abstract class and interface?

     

    Answer
    Abstract class:  An abstract class is a class that really isn’t supposed to ever be instantiated but instead serve as a base class to be inherited by other classes. Syntax->
             abstract class Class_name{
                 //insert attribute definitions here.
                 //insert method definitions here.
             }   
    Interface: An interface defines a general specification for implementing a particular service,   
                   declaring the required functions and constants without specifying exactly how it must be      
                   implemented. In PHP, an interface is created like so :
             Interface  InterfaceName{
    CONS 1;
    ………..
    CONS N;
    function methodName1();
    ……………………………………..
    function methodNameN();  
           } 






    1. Report
  5. Question:What are class and object?

     

    Answer
    Class: Classes are intended to represent those real-life items that we would like to manipulate within an application.

    Object: A class provides a basis from which we can create specific instances of the entity the class models, better known as objects. For example, an employee management application may include an Employee class. we can then call upon this class to create and maintain specific instances.






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd