affiliate_link

Wednesday, June 13, 2012

Ajax FAQ

1. What is Ajax?
Ajax stands for Asynchronous Java and XML. It is a set of client side technologies that allows asynchronous communication between client and server.
In synchronous communication complete round trip is performed with each Request/Response every time even when a small portion of data is to be refreshed. Ajax solves this problem of making a complete round trip to the server by making asynchronous calls
XMLHttpRequest is the basic fundamental behind Ajax which allows browser to communicate with web server without making post back

Sunday, June 10, 2012

OOP Q&A

1. What is the difference between Abstract class and Interface?
Abstract Class
An abstract class can have one or more abstract functions but not necessarily all functions have to be abstract.
Abstract function needs to be implemented in its extending class
Abstract classes can have function definitions as well as implementations

Interface
Interfaces can only have abstract functions which must be implemented in extending class

2. What is the difference between encapsulation and abstraction?

Encapsulation
Encapsulation means information hiding i.e hiding all the complexity in one class.
Encapsulation can be achieved by grouping data and behavior in one class that is capsule and making use of access modifiers like public, protected, private along with inheritance, composition or aggregation.

Like Vehicle class has start and stop behaviors which can be inherited by Car class without knowing all the complexities involving in the start & stop functions

Abstraction
Abstraction is the characteristics of an object which differs it from other objects
Abstraction can be achieved by defining a class having one or more abstract methods which is nothing but characteristics which should be implemented by the extending class

Friday, June 8, 2012

MySQL Q&A

MySQL Storage Engines

There are many but following three are commonly used:

1. MyISAM
    MyISAM is the default storage engine for MySQL

2. InnoDB
    InnoDB is a transaction safe (ACID compliant) storage engine for MySQL that has commit, rollback
    and crash recover capabilities to protect user data

3. Memory
    Memory storage engine creates tables with contents that are stored in memory. Memory/Heap tables are used for high speed temporary storage. Only Comparison operators supported (=, <=>). TEXT or BLOB fields are not supported. Auto Increment fields also not supported
   
Comparison 
Features                                MyISAM                   InnoDB                  Memory
Storage Limits                            256TB                         64TB                      RAM
Transaction                                 No                               Yes                         No
Locking                                      Table                            Row                       Table
Full Text Search Indexes             Yes                               No                         No
Clustered Indexes                        No                              Yes                         No                   
Replication Support                     Yes                              Yes                        Yes
Foreign Key                                No                               Yes                        No

What is the difference between MyISAM static and MyISAM dynamic?
MyISAM static tables fields are fixed length. MyISAM dynamic tables can have variable length fields
such as Text, BLOB etc

Advantages of MyISAM over InnoDB
 MyISAM tables are stored on disk which can therefore be compressed so it can accommodate a very large set of data 


Advantages of InnoDB over MyISAM
Transaction support, row level locking, foreign key constraints, crash recovery

What is Serial Data Type in MySQL?
BIGINT NOT NULL PRIMARY KEY AUTO INCREMENT

What are Federated Tables?
They are like linked tables in SQL Server which allows access to tables on different server

What is Candidate Key?
Any table that uniquely identifies a row in a table is candidate key for that table. We select one of the candidate keys as primary key

Difference between Primary Key and Unique Key
Primary Key
1. Uniquely identifies a column
2. Cannot be NULL
3. There can only be one primary key in a table

Unique Key
1. Uniquely identifies a column
2. Can be NULL
3, There can be more than unique keys

What is the difference between Drop Table and Truncate Table?
Drop table deletes table including data, structure, attributes & indexes
Truncate table deletes only the data


JSON Q&A

1. What is JSON?
JSON is a light weight, text based (human readable) open format used for data transformation.
JSON is language independent with parsers available in many languages
JSON is often used for serializing and transmitting structured data over a network connection.
Hence it is used as an alternative to XML    

2. Why JSON over XML?
 JSON
 (i)  Is lighter and faster than xml
 (ii) Objects are typed
 (iii) Data types in JSON can be number, string, bool, arrays whereas in xml only strings


3. How is JSON structured?
JSON is structured as a collection of name value pairs



Wednesday, May 30, 2012

PHP Q&A

1. How many are PHP super global variables?
(a)  $_REQUEST
(b)  $_POST
(c)  $_GET
(d)  $_COOKIES
(e)  $_SERVER
(f)   $_FILES
(g)  $_ENV

2. How can we get images properties like type, size, width, height?
For image type we can use           exif_imagetype()
Image size use                             getimagesize()
Image width                                 imagesx()
Image Height                               imagesy()

3. Get browser properties using PHP?
echo $_SERVER['HTTP_USER_AGENT'];

4. How many ways we can pass data between two pages using php?
(a) Register data in sessions
(b) Use cookies
(c) Pass value as GET or POST

5. How to make a script support multiple languages?
Set charset = UTF-8

6. What is the difference between Echo and Print in PHP?
Echo and print are more or less the same both outputs to the browser.
Difference is print() only takes one argument and returns true on successful printing
Echo is slightly faster than print

7. How to prevent hacking in PHP?
(a) Set Register_globals to OFF to prevent form injection with malicious data
(b) Set Error Reporting to E_ALL to show all error messages
(c) Validate input using htmlentities(), strip_tags(), utf8_decode() & addslashes()

8. What is the difference between Notify URL and Return URL using Paypal?
Notify URL
Notify URL is used by PayPal IPN for sending transaction information 

Return URL
The url to which user is returned after successful payment


9. What is ob_start()?
ob_start() turns on the output buffering. When buffering is ON any output sent from server will be stored in a buffer until ob_end() is called or script ends.
It eliminate Headers already sent problem


Monday, May 28, 2012

How to set dropdown value using jquery?

If you know the value you can set it like this 
 
$("#myddl").val("somevalue");
 
Setting through index
 
$("#mydropdownlist").attr('selectedIndex', 0);