YouTube Icon

Interview Questions.

Top 100+ Object Oriented Programming In Php Interview Questions And Answers - May 31, 2020

fluid

Top 100+ Object Oriented Programming In Php Interview Questions And Answers

Question 1. What Is Object Oriented Programming?

Answer :

Object-orientated programming (OOP) is a programming language model organized around objects in place of moves;

Objects are times of classes, are used to engage with each other.

Following are few examples of item-oriented programming languages

PHP, C++, Objective-C, Smalltalk, C#, Perl, Python, Ruby.

The goals of item-oriented programming are:

Increased knowledge.
Ease of renovation.
Ease of evolution.
Question 2. What Is Data Modeling?

Answer :

In class, we create a couple of get/set characteristic to get and set the facts through the blanketed functions referred to as Data Modeling.

Magnificence dataModel     

    public characteristic __set( $key, $price ) 

        $this->$key = $fee;

     

Following are the benefits of Data Modeling:

It is very speedy.
Smart way to  manipulation on facts
No greater layer of logic 
Really flexible to be modeled according to want 
Setters can explicitly outline what records can be loaded into the object
PHP Interview Questions
Question three. What Is Difference Between Class And Interface?

Answer :

Interfaces do now not contain business common sense 
You should enlarge interface to use.
You cannot create object of interface.
Question 4. How Session - Cookie Works In Php?

Answer :

When a website open in new purchaser device(Browser), new sessionId is created and saved in php server and in consumer device (In cookie).

All facts is shop in PHP Server and cookie most effective have sessionId. When patron send sessionId with request to the server, then server fetch the records corresponsing to that sessionId and retun to the browser.

PHP Tutorial
Question 5. What Are Some Of The Big Changes Php Has Gone Through In The Past Few Years?

Answer :

five.1 delivered PDO 

5.3 - added namespace help 

Zend Interview Questions
Question 6. What Is Polymorphism?

Answer :

It is without a doubt "One factor, can use in distinct paperwork"

For example, One vehicle (elegance) can amplify  lessons (hond & Alta)

Question 7. How To Load Classes In Php?

Answer :

We can load a category with the use of "autoload" elegance.
If we want to exchange from default function autoload to testautload feature.
We will try this with "spl_autoload_register" 
spl_autoload_register('kumar');
Zend Tutorial PHP and Jquery Interview Questions
Question 8. How To Call Parent Constructor?

Answer :

determine::__construct()

Question nine. Are Parent Constructor Called Implicitly When Create An Object Of Class?

Answer :

No, Parent constructors are not known as implicitly It need to name this explicitly. But If Child constructors is missing then determine constructor known as implicitly. 

PHP+MySQL Interview Questions
Question 10. What Happen, If Constructor Is Defined As Private Or Protected?

Answer :

If constructor declared as personal, PHP thru the subsequent fatal blunders whilst create object.

Fatal blunders: Call to personal BaseClass::__construct() from invalid context in. If constructor declared as non-public, PHP via the following deadly mistakes when create object. Fatal errors: Call to blanketed BaseClass::__construct() from invalid context in.

PHP and Jquery Tutorial
Question eleven. What Happen, If New-style Constructor & Old-fashion Constructor Are Defined. Which One Will Be Called?

Answer :

New-Style constructor will known as. But if New-Style constructor is lacking, vintage fashion constructor will called. 

Sybase Interview Questions
Question 12. What Are Different Visibility Of Method/belongings?

Answer :

There are three styles of visibility of method & belongings and are following

Public: Can be accessed from same magnificence technique, infant class and from out of doors of class.

Protected : Can be accessed from same magnificence technique, baby magnificence.

Private: Can be accessed from equal class method only. 

Class TestClass

    public $public = 'Public';

    covered $included = 'Protected';

    non-public $non-public = 'Private';

 function printValue()

    

        echo $this->public;

        echo $this->included;

        echo $this->private;

    

$obj = new TestClass();

echo $obj->public; // Works

echo $obj->protected; // Fatal blunders: Cannot get right of entry to covered assets TestClass::$covered in

echo $obj->private; // Fatal errors: Cannot get entry to private property TestClass::$non-public in C:wampwwwarunclassclass.Php on-line 20

$obj->printValue(); // Shows Public, Protected and Private 

PHP Interview Questions
Question thirteen. What Is Scope Resolution Operator?

Answer :

The Scope Resolution Operator (additionally known as Paamayim Nekudotayim) is double colon that allows get right of entry to to static, steady, and overridden properties or methods of a category.

Following are distinctive makes use of Access to static

Acess the constant
Access the overridden homes of parent elegance
Access the overridden techniques of a figure magnificence
Magento Tutorial
Question 14. What Is Static Keyword In Php?

Answer :

If we declare a Method or Class Property as static, then we will get right of entry to that without use of instantiation of the magnificence.
Static Method are faster than Normal technique.
$this isn't available inside Static Method.
Static houses cannot be accessed via the object(i.E arrow operator)
Calling non-static strategies with Scope Resolution operator, generates an E_STRICT degree warning.
Static residences may most effective be initialized the usage of a literal or constant fee.
Static residences/Normal houses Can't be initialized the usage of expressions cost.
Magnificence StaticClass

    public static $staticValue = 'foo';

 

    public feature staticValue() 

        return self::$my_static;

    

echo StaticClass::$staticValue;

Question 15. What Is Abstraction In Php?

Answer :

Abstraction are described the usage of the key-word summary .
PHP five introduces summary training and strategies. Classes described as abstract might not be instantiated (create item).
To extend the Abstract elegance, extends operator is used.
You can inherit best one summary class at one time extending.
Any class that consists of one summary method ought to additionally be declare as summary. Methods described as abstract virtually claim the approach's signature, they can't outline the implementation.
All methods marked as abstract in the parent's magnificence, assertion need to be described by the kid.
Moreover, these methods have to be defined with the equal (or a less restrained) visibility (Public,Protected & private).
Type hint & wide variety of parameter should be healthy between discern & toddler magnificence.
Dbase Interview Questions
Question sixteen. What Is Interface In Php?

Answer :

Interfaces are defined the use of the interface key-word.
All methods declared in an interface ought to be public. Classes defined as Interface might not be instantiated(create item).
To extend the interface magnificence, implements operator is used.
You can inherit number of interface elegance on the time of extending and variety of summary elegance separated via comma.
All strategies in the interface have to be carried out inside a infant elegance; failure to do so will result in a fatal mistakes.
Interfaces can be prolonged like instructions the use of the extends operator.
The magnificence enforcing the interface have to use the exact equal method signatures as are described within the interface. Not doing so will bring about a fatal errors.
Type hint & number of parameter must be match.
WordPress Tutorial
Question 17. What Is Traits In Php?

Answer :

Traits are a mechanism for code reuse in single inheritance.
A Trait is similar to a category, however best intended to group functionality in a satisfactory-grained and constant manner. 
It isn't viable to instantiate a Trait however addition to traditional inheritance. It is intended to lessen a few boundaries of single inheritance to reuse sets of strategies freely in several independent instructions residing in one-of-a-kind magnificence hierarchies.
Multiple Traits may be inserted into a category through listing them inside the use declaration, separated by means of commas(,).
If two Traits insert a method with the same call, a deadly errors is produced.
Example of Traits:

magnificence BaseClass

    characteristic getReturnType() 

        go back 'BaseClass';

    

trait traitSample 

    function getReturnType() 

        echo "TraitSample:";

        determine::getReturnType();

        

magnificence Class1 extends BaseClass 

    use traitSample;   

$obj1 = new Class1();

$obj1->getReturnType();//TraitSample:BaseClass

Magento Interview Questions
Question 18. What Is Overloading?

Answer :

It is dynamically create technique / residences and carried out by using magic methods. Overloading technique / residences are invoked whilst interacting with residences or techniques that have not been declared or aren't seen within the modern-day scope, Means we you are calling a function which isn't always exist. None of the arguments of these magic techniques can be handed via reference.

In PHP, Overloading is feasible http://2 hundred-530.Blogspot.In/2013/04/oop-magic-methods.Html

Zend Interview Questions
Question 19. What Is Object Iteration?

Answer :

PHP affords a way for objects to be iterate via a list of items, for this we will use foreach. Only visible houses may be indexed. 

Magnificence TestClass

    public $public='PublicVal';

    covered $included='ProtectedVal';

    private $personal='PrivateVal';

      characteristic myfunc() 

        return 'func';

    

     feature iterateVisible()

        foreach($this as $key => $price) 

           print "$key => $valuen";

       

    

$obj=new TestClass();

$obj->iterateVisible(); 

CakePHP Tutorial
Question 20. What Is Final Keyword In Php?

Answer :

PHP introduces the final key-word, which prevents child lessons from overriding a way through prefixing the definition with final.

If the elegance itself is being defined very last then it cannot be extended. If the characteristic itself is being described very last then it cannot be prolonged. 

PHP5 Interview Questions
Question 21. What Is Serialize Function In Php?

Answer :

It go back string containing a byte-move illustration of any fee that can be saved in PHP.

Question 22. Comparing Objects?

Answer :

When using the evaluation operator (==), item variables are in comparison in a easy way, namely: Two item instances are same in the event that they have the equal attributes and values, and are times of the equal elegance.

When the use of the identity operator (===), item variables are identical if and handiest in the event that they check with the equal example of the identical magnificence

CodeIgniter Tutorial
Question 23. What Is Uml?

Answer :

UML stands for Unified Modeling Language.

You can do following matters with UML:

Manage undertaking complexity.
Create database schema.
Produce reviews.
WordPress Interview Questions
Question 24. What Are Properties Of Object Oriented Systems?

Answer :

Inheritance
Encapsulation of statistics
Extensibility of current records sorts and instructions
Support for complicated statistics sorts
Aggregation
Association
PHP and Jquery Interview Questions




CFG