Are you preparing for an Object Oriented Programming in PHP job? Then you are at the right place for getting good interview questions that can land your dream job. Object Oriented Programming in PHP is a programming process to divide alike tasks into Class and Object to generate reusable code. As we can visualize things as different parts like a car made of different things like the wheel, steering, body, gear etc. There are several Object Oriented Programming in PHP jobs available in reputed organizations for various positions like Software Development Engineer, System Engineer, Software Developer, Lecturer, Application Developer, Consultant, Team Leader, Dot Net Developer etc. know more about Object Oriented Programming in PHP job interview Questions please visit our Object Oriented Programming in PHP job interview questions and answers page designed by wisdomjobs professional experts.
Question 1. What Is Object Oriented Programming?
Answer :
Object-oriented programming (OOP) is a programming language model organized around objects rather than actions;
Objects are instances of classes, are used to interact with one another.
Following are few examples of object-oriented programming languages
PHP, C++, Objective-C, Smalltalk, C#, Perl, Python, Ruby.
The goals of object-oriented programming are:
Question 2. What Is Data Modeling?
Answer :
In class, we create multiple get/set function to get and set the data through the protected functions known as Data Modeling.
class dataModel {
public function __set( $key, $value ) {
$this->$key = $value;
}
}
Following are the benefits of Data Modeling:
Question 3. What Is Difference Between Class And Interface?
Answer :
Question 4. How Session - Cookie Works In Php?
Answer :
When a website open in new client machine(Browser), new sessionId is created and stored in php server and in client machine (In cookie).
All data is store in PHP Server and cookie only have sessionId. When client send sessionId with request to the server, then server fetch the data corresponsing to that sessionId and retun to the browser.
Question 5. What Are Some Of The Big Changes Php Has Gone Through In The Past Few Years?
Answer :
5.1 added PDO
5.3 - added namespace support
Question 6. What Is Polymorphism?
Answer :
It is simply "One thing, can use in different forms"
For example, One car (class) can extend two classes (hond & Alta)
Question 7. How To Load Classes In Php?
Answer :
Question 8. How To Call Parent Constructor?
Answer :
parent::__construct()
Question 9. Are Parent Constructor Called Implicitly When Create An Object Of Class?
Answer :
No, Parent constructors are not called implicitly It must call this explicitly. But If Child constructors is missing then parent constructor called implicitly.
Question 10. What Happen, If Constructor Is Defined As Private Or Protected?
Answer :
If constructor declared as private, PHP through the following fatal error when create object.
Fatal error: Call to private BaseClass::__construct() from invalid context in. If constructor declared as private, PHP through the following fatal error when create object. Fatal error: Call to protected BaseClass::__construct() from invalid context in.
Answer :
New-Style constructor will called. But if New-Style constructor is missing, old style constructor will called.
Question 12. What Are Different Visibility Of Method/property?
Answer :
There are 3 types of visibility of method & property and are following
Public: Can be accessed from same class method, child class and from outside of class.
Protected : Can be accessed from same class method, child class.
Private: Can be accessed from same class method only.
class TestClass
{
public $public = 'Public';
protected $protected = 'Protected';
private $private = 'Private';
function printValue()
{
echo $this->public;
echo $this->protected;
echo $this->private;
}
}
$obj = new TestClass();
echo $obj->public; // Works
echo $obj->protected; // Fatal error: Cannot access protected property TestClass::$protected in
echo $obj->private; // Fatal error: Cannot access private property TestClass::$private in C:wampwwwarunclassclass.php on line 20
$obj->printValue(); // Shows Public, Protected and Private
Question 13. What Is Scope Resolution Operator?
Answer :
The Scope Resolution Operator (also called Paamayim Nekudotayim) is double colon that allows access to static, constant, and overridden properties or methods of a class.
Following are different uses Access to static
Question 14. What Is Static Keyword In Php?
Answer :
class StaticClass
{
public static $staticValue = 'foo';
public function staticValue() {
return self::$my_static;
}
}
echo StaticClass::$staticValue;
Question 15. What Is Abstraction In Php?
Answer :
Question 16. What Is Interface In Php?
Answer :
Question 17. What Is Traits In Php?
Answer :
Example of Traits:
class BaseClass{
function getReturnType() {
return 'BaseClass';
}
}
trait traitSample {
function getReturnType() {
echo "TraitSample:";
parent::getReturnType();
}
}
class Class1 extends BaseClass {
use traitSample;
}
$obj1 = new Class1();
$obj1->getReturnType();//TraitSample:BaseClass
Question 18. What Is Overloading?
Answer :
It is dynamically create method / properties and performed by magic methods. Overloading method / properties are invoked when interacting with properties or methods that have not been declared or are not visible in the current scope, Means we you are calling a function which is not exist. None of the arguments of these magic methods can be passed by reference.
In PHP, Overloading is possible http://200-530.blogspot.in/2013/04/oop-magic-methods.html
Question 19. What Is Object Iteration?
Answer :
PHP provides a way for objects to be iterate through a list of items, for this we can use foreach. Only visible properties will be listed.
class TestClass{
public $public='PublicVal';
protected $protected='ProtectedVal';
private $private='PrivateVal';
function myfunc() {
return 'func';
}
function iterateVisible(){
foreach($this as $key => $value) {
print "$key => $valuen";
}
}
}
$obj=new TestClass();
$obj->iterateVisible();
Question 20. What Is Final Keyword In Php?
Answer :
PHP 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 cannot be extended. If the function itself is being defined final then it cannot be extended.
Question 21. What Is Serialize Function In Php?
Answer :
It return string containing a byte-stream representation of any value that can be stored in PHP.
Question 22. Comparing Objects?
Answer :
When using the comparison operator (==), object variables are compared in a simple manner, namely: Two object instances are equal if they have the same attributes and values, and are instances of the same class.
When using the identity operator (===), object variables are identical if and only if they refer to the same instance of the same class
Answer :
UML stands for Unified Modeling Language.
You can do following things with UML:
Question 24. What Are Properties Of Object Oriented Systems?
Answer :
Object Oriented Programming in PHP Related Tutorials |
|
---|---|
PHP Tutorial | Zend Tutorial |
PHP and Jquery Tutorial | Magento Tutorial |
WordPress Tutorial | CakePHP Tutorial |
CodeIgniter Tutorial | Firebase Tutorial |
PHP7 Tutorial |
Object Oriented Programming in PHP Related Practice Tests |
|
---|---|
PHP Practice Tests | Zend Practice Tests |
PHP and Jquery Practice Tests | PHP+MySQL Practice Tests |
Sybase Practice Tests | Dbase Practice Tests |
Magento Practice Tests | PHP5 Practice Tests |
WordPress Practice Tests | CakePHP Practice Tests |
CodeIgniter Practice Tests |
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.