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
  6. Question:What is property overloading?

     

    Answer
    Property overloading continues to protect properties by forcing access and manipulation through public methods, yet allowing the data to be accessed as if it were a public property. These methods, known as accessors and mutators, or more informally as getters and setters, are automatically triggered whenever the property is accessed or manipulated, respectively.

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

     

    Answer
    PHP does not support multiple inheritances. Implementation of multiple interfaces is supported.


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

     

    Answer
    Abstract class: An abstract class is a class that cannot be instantiated. Abstract classes are intended to be inherited by a class that can be instantiated, better known as a concrete class. Abstract classes can be fully implemented, partially implemented or not implemented at all.

    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.

    1. Report
  9. Question:What is the meaning of a final class and a final method? 

    Answer
    Final keywords indicates that the class or method cannot be extended.

    1. Report
  10. Question:How do you execute a PHP script from the command line? 

    Answer
    Just use the PHP command line interface (CLI) and specify the file name of the script to be executed as follows:
    php script.php

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