Friday, 27 April 2012

PHP Interview question 8


21) How can we encrypt the username and password using PHP?
Ans :  The functions in this section perform encryption and decryption, and compression and uncompression:
encryption                   decryption
AES_ENCRYT()        AES_DECRYPT()
ENCODE()                 DECODE()
DES_ENCRYPT()      DES_DECRYPT()
ENCRYPT()                Not available
MD5()                         Not available
OLD_PASSWORD()  Not available
PASSWORD()            Not available
SHA() or SHA1()       Not available
Not available              UNCOMPRESSED_LENGTH()       
 
22) What are the features and advantages of object-oriented programming?
Ans :      One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns.
For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system     
             
23) What are the differences between procedure-oriented languages and object-oriented languages?
Ans :      There are lot of difference between procedure language and object oriented like below
1>Procedure language easy for new developer but complex to understand whole software as compare to object oriented model
2>In Procedure language it is difficult to use design pattern mvc , Singleton pattern etc but in OOP you we able to develop design pattern
3>IN OOP language we able to ree use code like Inheritance ,polymorphism etc but this type of thing not available in procedure language on that our Fonda use COPY and PASTE .      

24) What is the use of friend function?
Ans :      Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class.
A friend declaration is essentially a prototype for a member function, but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match.

25) What are the differences between public, private, protected, static, transient, final and volatile?
Ans:       Public: Public declared items can be accessed everywhere.
Protected: Protected limits access to inherited and parent classes (and to the class that defines the item).
Private: Private limits visibility only to the class that defines the item.
Static: A static variable exists only in a local function scope but it does not lose its value when program execution leaves this scope.
Final: Final keyword 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.
transient: A transient variable is a variable that may not be serialized.
volatile: a variable that might be concurrently modified by multiple threads should be declared volatile. Variables declared to be volatile will not be optimized by the compiler because their value can change at
any time.

No comments:

Post a Comment