• What is the relation between Classes and Objects in php OOPS System?

    What is the relation between Classes and Objects in php OOPS System?

    Bronze Member Asked on December 29, 2016 in Wordpress.
    Add Comment
  • 1 Answer(s)
    Best answer

    Class is a definition, while object is a instance of the class created.
    class is like a blueprint/template in OOPs, and this template is used to create objects.The collection of properties & behavior of an object is also called as class. A class contains properties, fields, data members, attributes.

    Car is an object , cars is a class

    
    public class cars
    
    {
    
    //
    
    }
    
    

    According to the sample given below we can say that the cars object, named object_car, has created out of the cars class.
    
    cars object_car = new cars();
    
    

    object is an instance of a class.An object is an entity that has attributes, behavior, and identity. Objects are members of a class.
    Objects are accessed, created or deleted during program run-time.

    Declaration of an Object in OOPs
    ClassName objectName=new ClassName();
    Example:

    
    Car objCar= new Car();
    
    

    Attribute in OOPs: Attributes define the characteristics of a class. In Class Program attribute can be a string or it can be a integer.
    Behavior in OOPS: Every object has behavior.
    Identity in OOPS: Each time an object is created the object identity is been defined.

    Watch Video In Youtube

            

     

    Bronze Member Answered on December 29, 2016.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.