Questions on OOP concepts
1. What are the access specifiers available in php ? Explain
2. What is object cloning ?
3. What are the differences between interface and abstract
class ?
4. What is overloading ?
5. What is overriding ?
6. How to prevent function overriding ?
7. What is the use of "final" keyword ?
8. What is static variable ? How will access a static
variable ? What is static class ?

Answer Posted / raghu

Answer according to question no
1. Three access specifiers:
public : can be accessed outside class by any child class
private : can be accessed by only members of class
protected : can be accessed in derived class having
protected methods or variables not by other

2. Making copy of object is nothing but object cloning
e.g. $copy_of_object = clone $object;

3.You neither able to create object of interface nor
abstract class. Difference: In abstract class, u can declare
as well as define methods but in interface u can not define
method u can only declare.

7. Final keyword is used to prevent child class from
overriding method of parent class.

8. Declaring class members or methods as static makes them
accessible without needing an instantiation of the class. A
member declared as static can not be accessed with an
instantiated class object (though a static method can).
Static properties cannot be accessed through the object
using the arrow operator ->.

Is This Answer Correct ?    20 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How are cookies created?

637


What is basename php?

598


What is str_replace()?

637


Do you know what is the difference between mysql_fetch_object() and mysql_fetch_array()?

599


Which is variable cost?

620






List few sensible functions in PHP?

647


How to replace a substring in a given string in php?

622


Explain the difference between urlencode and urldecode?

619


What’s the special meaning of __sleep and __wakeup?

645


What would occur if a fatal error was thrown in your php program?

629


What are the different ways to login to a remote server? Explain the me, advantages and disadvantages?

640


What is csrf mvc?

598


Who is known as the father of php?

652


Explain the difference between mysql_connect and mysql_pconnect?

555


armstrong number by using php while number is given by the keyboard.?

1781