InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What Are Properties Of Object Oriented Systems? |
Answer»
|
|
| 2. |
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 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 |
|
| 3. |
What Is Serialize Function In Php? |
|
Answer» It RETURN string CONTAINING a byte-stream representation of any value that can be STORED in PHP. It return string containing a byte-stream representation of any value that can be stored in PHP. |
|
| 4. |
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. 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. |
|
| 5. |
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(); 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(); |
|
| 6. |
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 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 |
|
| 7. |
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 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 |
|
| 8. |
What Is Interface In Php? |
Answer»
|
|
| 9. |
What Is Abstraction In Php? |
Answer»
|
|
| 10. |
What Is Static Keyword In Php? |
Answer»
class StaticClass { public static $staticValue = 'foo';
public function staticValue() { return self::$my_static; } } echo StaticClass::$staticValue; class StaticClass { public static $staticValue = 'foo';
public function staticValue() { return self::$my_static; } } echo StaticClass::$staticValue; |
|
| 11. |
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
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 |
|
| 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 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 |
|
| 13. |
What Happen, If New-style Constructor & Old-style Constructor Are Defined. Which One Will Be Called? |
|
Answer» New-STYLE CONSTRUCTOR will CALLED. But if New-Style constructor is MISSING, OLD style constructor will called. New-Style constructor will called. But if New-Style constructor is missing, old style constructor will called. |
|
| 14. |
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. 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. |
|
| 15. |
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. No, Parent constructors are not called implicitly It must call this explicitly. But If Child constructors is missing then parent constructor called implicitly. |
|
| 16. |
How To Call Parent Constructor? |
|
Answer» PARENT::__construct() parent::__construct() |
|
| 17. |
How To Load Classes In Php? |
| Answer» | |
| 18. |
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 |
|
| 19. |
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. 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. |
|
| 20. |
What Is Difference Between Class And Interface? |
Answer»
|
|
| 21. |
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:
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: |
|