Saturday, March 12, 2011

Interview Questions

1>How to retrieve the second largest salary of different department without using the limit statement (MYSQL) ?

Ans : select dept, max(salary) from deptemp where salary not in (select max(salary) from deptemp group by dept) group by dept .

2>What is the effect of large number of data stored in a database on a website ? i.e. if there is a 5,00,000 records on the database is it affect website. what is the solution for this.

Answer a > The best way to solve this problem use web tester like funkload web tester is free. Thanks


3> Would you initialize your strings with single quotes or double quotes?
Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution


4> How do you insert single & double qotes in MySql db without using PHP?
we can use addslashes function for this

5>What are magic quotes in PHP?
Some special characters in PHP like single quote( ' ) double quote( ) amperson ( & ) etc. are escape by slash its called magic quotes. Its useful for beginner programmer.

6>what are the various methods to pass data from one web page to another web page ?
1.POST
2.GET
3.SESSION
4.COOKIES
5.QUERY STRING
GET
HEAD
POST
PUT
DELETE
TRACE
CONNECT
OPTIONS
REF: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

7>How many types of tables are there in MYSQL database?
MySQL 5.1 supports the following storage engines:
MyISAM
InnoDB
Memory
Merge
Archive
Federated
NDB
CSV
Blackhole

8>What is 'htmlentities' and it's relationship with preventing XSS attacks/vulnerabilities?
XSS or crossite attacks is like when you change the URL and try to change the form submit for attacking to the server for some hacking or such stuffs. e.g. : www.mysite.com?name=pradip can be easily attacked if there is no "htmlentities" which filters all the html tags, by using like : www.mysite.com?name='pradip; drop table
test;'

9>What is the difference between if-else-if and switch statement?
The case expression may be any expression that evaluates to a simple type, that is, integer or floating-point numbers and strings. Arrays or objects cannot be used here unless they are dereferenced to a simple type.

10> What is the difference between echo and print statement?
echo and print are both language constructs and do not (and should not) require parenthesis. The difference is that print returns a value indicating success where echo does not
echo() can take multiple expressions Print cannot take multiple expressions.
echo has the slight performance advantage because it doesn't have a return value.
You can use something link $a print $b while you cant use $a echo $b.
Both are language construct.
The only difference is:
print can evealuate expression and
echo can not.


11>What's the difference between COPY OF A FILE & MOVE_UPLOAD_FILE in file uploading?
Move : This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
Copy :Makes a copy of a file. Returns TRUE if the copy succeeded, FALSE otherwise

No comments:

Post a Comment