Priti's Technical Corner

October 3, 2009

PHP Interview Questions


Question 1: What is class?
Answer 1: Class is a collection of variables and method.

Question 2: What is data encapsulation and how to achieve it PHP?
Answer 2: Data encapsulation is hiding the member variables and method from the access of others.In PHP data encapsulation is implementated with concept called Class. Class is the collection of variable and method whoes access to other classes is defined in the class  itself.

Question 3: Can constructors can be inherited in PHP5?
Answer 3: Yes

Question 4: what is the difference between errors and exceptions?
Answer 4: An error is a fatal to the programs’s ability to do its job. Where as an exception is a stituation which is uncommon but recoverable.

Question 5:what is difference between class variables and class constants?
Answer 5: class vairables are declared with keyword static and can be changed.Class constants are declared with keyword ‘const’ and can’t be changed.

Question 6: Can we define value of constant inside methods in a class?
Answer 6: No.Values of constant can be set on;y when it’s deifned.

Question 7:what is concrete class?
Answer 7:concrete class is a term used for class which are not abstract.

Question 8:If a method is declared as abstract then, the class containing must also be declared as abstract?
Answer 8:Yes

Question 9: what is abstract methods?
Answer 9:abstract methods is just a declaration of method signature with keyword ‘abstract’.

Question 10: Can concrete class can have abstract methods?
Answer 10: No

Advertisements

3 Comments »

  1. Thanks for these useful questions… please keep up the good work.

    Comment by Sashi Kanth — October 9, 2011 @ 5:46 pm

  2. thanks

    Comment by chella pandian — March 30, 2013 @ 1:25 pm

  3. Good queastion…..thanx

    Comment by Kuldeep Shukla — July 30, 2013 @ 10:57 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: