Phone Screen Lamp)

14
PHP Questions:- 1. What difference is between include and require?  Answer: It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt execution. If the file is not found by include(), a warning will be issued, but execution will continue. 2. Explai n cook ies and sessions. Answer: A cookie is a small piece of information that is generated by the server but stored on the client. A session is a logical o bject created by the PHP engine to allow you to preserve data across subsequent HTTP requests. 3. What wi ll happen register _globa ls is enabled in php.ini? Answer: If enabled, all form variables can become global variables. It is not secured. So it is disabled. 4. What are the different access or visibility modifiers?  Answer: Private, protected and public. Private: Private Properties and private methods can be accessed only within the class. Public: Public properties/methods can be accessed outside the class scope. Protected: Protected properties/methods can be accessed from the class and it’s subclasses/inheriting classes. 5. Name fe w magic met hod s?  Answer:  __construct, __destru ct, _ _call, __clon e, __ sleep,  __wak eup,  __invok e 6. Wha t d oes __c lone d o?  Answer: Used to create a shallow copy(copying by value not by reference) of the object. 7. Exp lai n abstr act clas s.  Answer: A class which can contain concrete and abstract methods but cannot be instantiated/ we can’t cre ate objects of the abstract class. 8. What a re the tr adeoffs /disad vantages using indexes? Answer: 1. slower updates/inserts. 2. Extra storage space to store indexes. 9. What i s the differ ence be tween split and explod e?  Answer: Explode is faster and used to split a string into an array using delimiter. Split - Splits a string into array by regular expression and it deprecated. 10. What are magic quotes? Would you say they're useful?

Transcript of Phone Screen Lamp)

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 1/14

PHP Questions:-

1. What difference is between include and require?

  Answer: It’s how they handle failures. If the file is not found byrequire(), it will cause a fatal error and halt execution. If the file is not found byinclude(), a warning will be issued, but execution will continue.

2. Explain cookies and sessions.Answer: A cookie is a small piece of information that is generated by

the server but stored on the client. A session is a logical object created by thePHP engine to allow you to preserve data across subsequent HTTP requests.

3. What will happen register_globals is enabled in php.ini?Answer: If enabled, all form variables can become global variables. It

is not secured. So it is disabled.

4. What are the different access or visibility modifiers?  Answer: Private, protected and public.

Private: Private Properties and private methods can be accessed only withinthe class.Public: Public properties/methods can be accessed outside the class scope.Protected: Protected properties/methods can be accessed from the class andit’s subclasses/inheriting classes.

5. Name few magic methods?  Answer: __construct, __destruct, __call, __clone, __sleep, __wakeup,

 __invoke

6. What does __clone do?  Answer: Used to create a shallow copy(copying by value not by

reference) of the object.

7. Explain abstract class.  Answer: A class which can contain concrete and abstract methods

but cannot be instantiated/ we can’t create objects of the abstract class.

8. What are the tradeoffs/disadvantages using indexes?Answer: 1. slower updates/inserts. 2. Extra storage space to

store indexes.

9. What is the difference between split and explode?  Answer: Explode is faster and used to split a string into an array

using delimiter.Split - Splits a string into array by regular expression and it deprecated.

10. What are magic quotes? Would you say they're useful?

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 2/14

  Answer: When any of PHP's various magic_quotes_* settings areenabled in php.ini, PHP will automatically escape single quotes, double quotes, backslashes, and null characters with a backslash. This wasintended to provide "automatic" protection against SQL injection and othersecurity risks, but in reality it's virtually useless as a security measure and onlyends up introducing unexpected bugs (like the infamous \' issue that plagues

many PHP sites to this day). Magic quotes were deprecated in PHP 5.311. Difference between Get and Post?• Get – Data encoded into a URL• Post – Data within message body12. How to handle file uploads in php?

Answer: In the form, set the method to post and enctype tomultipart/form-data and after uploading, use the $_FILES variable for accessingthe uploaded file.

13. What is opcode caching? Or, mention how PHP executes code.  Answer:

PHP converts code into an intermediate bytecode format and executes it and

throws away the bytecode. An opcode caching engine sits in between this layer(written as an extension) and stores the bytecode and feeds it to PHP avoidingthe overhead of compilation everytime. Example of opcode caching enginesare APC, Turck MMCache, PHP Accelerator, etc.

14. What is the difference between hash and encrypt?Answer: hash -- a ONE-WAY scrabbling of a known input to random

data. Nobody in the world should be able to convert the scrabbled data back tothe original input.

encrypt -- a TWO-WAY scrabbling of a known input to arandom data. But the random data can be un-scrabbled to the original input. That's call decrypt or deciper. 

15. What does the triple equal to (=) operator do?Answer: It checks the value as well as the type of the value for

equality.

16. Difference between print and echo().Answer: The "print" is not a function but a language construct. The

"echo" is a language construct and does not return any value. The "echo" canbe marginally faster than "print" since it does not return any value.

17. Different types of web attacks/vulnerabilities?Answer:

DoS (Denial of Service)Session HijackingCross Site Scripting (XSS attacks)Mysql InjectionBuffer Overflow

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 3/14

18. Can we pass special characters through URL? How will you do?mb_string functions

19. How do you wrap unicode strings?

AJAX

1. How many types of ready states in ajax? There are 5 readyStates0 = uninitialized1 = loading2 = loaded3 = interactive4 = complete

2. Is it possible to set session variables from JavaScript?

It's not possible to set any session variables directly from JavaScript as it is purely a client side technology. You can use AJAXthough to asynchronously to set the session variables.

3. What is the command to stop Apache?service httpd stop or apachectl stop

4. What is the XMLHttpRequest object?It offers a non-blocking way for JavaScript to communicate back tothe web server to update only part of the web page.

CSS

5. What are the five possible values for "position"?Values for position: static, relative, absolute, fixed, inherit.

6. What is the default/initial value for "position"?Static

7. What is Document Type Definition?Document Type Definition (DTD) specifies the syntax of a web

page in SGML; it is used to specify rules that apply to the markupof the document of a particular type, including a set of elementand entity declarations.

8. What are the possible values for the display attribute thatare supported by all browsers?none, block, inline, list-item, run-in

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 4/14

9. Difference between “visibility:hidden” and“display:none”?When visibility is set to hidden, the element being hidden stilloccupies its same place in the layout of the page. If the display isset to none, the element does not occupy any space on the page

HTML

10. How do you make decision when to use use HTML &XHTML ?HTML and XHTML are very similar but XHTML follows a stricter setof rules making it easier to validate data and design pages

11. What are differences between DIV and SPAN?Div is a Container(Block element) where we can place our dataimage text or anything and span(inline element) is used forformating. 

12. What are the differences between cell spacing andcell padding?Cellpadding: it is used to increase the size of cells.Cellspacing:it is used to make space between cells.

13. What is meant by iframe?Frame is used for creating a inline frame or floating frame thatcontains another document.

14. Why error "HTTP Status 500"?NullPointer Exception is a typical exception thrown when you triesto set incompatible datatypes without casting them

 JAVASCRIPT

15. What is negative infinity?It’s a number in JavaScript, derived by dividing negative numberby zero.

16. What does isNaN function do?Return true if the argument is not a number.

17. How to disable back option by JavaScript?window.history.go(+1)

18. What does undefined value mean in JavaScript?

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 5/14

Undefined value means the variable used in the code doesnt existor is not assigned any value or the property doesnt exist.

19. What does JavaScript null mean? The null value is a unique value representing no value or no

object.It implies no object, or null string, no valid Boolean value, nonumber and no array object.

MySQL

20. What’s the default port for MySQL Server?3306

21. What are CSV tables? Those are the special tables, data for which is saved into comma-

separated values files. They cannot be indexed.

22. What’s the difference between CHAR_LENGTH andLENGTH? The first is, naturally, the character count. The second is bytecount.

23. What are CLUSTERS?A CLUSTER is a means of storing together data from multipletables, when the data in those tables contains information and islikely to be accessed concurrently.

24. What is the maximum length of a table name,database name, and fieldname in MySQL?table -64/ database- 64/columns-64alias-255

Interview Questions ( Zynga)

1. What is GREP command in Linux?

Ans:Grep is a unix command/utility to search a given text/pattern infiles.

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 6/14

2. Can we apply any command on the ouput of other command and how?

Ans:Using pipeline ex ps –ax | grep Finder

3. What are the cookies?Ans:Cookies are the message/response created bythe web server when you visit a websites.They are small files containinginfo ,saved on clients hard disk.

4. What is the difference b/w include and require ?

Ans:Both are same but include creates warning if the included file ismissing and require creates a fatal error and stops execution of script.

(Maximum questions from his current project desitara.com) 

• Why don't you have .php extension in the url ondesitara.com/talent/contest?Ans:Search engines don’t include dynamic web pages (sees ?)into there

search like product.php?id=5 and includes only static htmls like product-5.html.so you have it include you have to rewrite rule 1)mod_rewrite,followsymlinks module enabled in apache2) create .htaccess in rootfolder and write ruleOptions +FollowSymlinksRewriteEngine onRewriteRule ^(.*)\.htm$ $1.php [nc]RewriteRule ^product-([0-9]+)\.html$ products.php?id=$1

• Seo optimization - how it works? is the process of improving the visibility of a website or a web page in search engines via

the "natural" or un-paid ("organic" or "algorithmic") search results. SERP1)White hat tech

->creating keywords in meta tag,title and headers and good content having keywords->link analysis,other pages linking to your page2)black hat tech->keyword stuffing(background same color,footer has keywords->Page stuffing(creating duplicate pages)->selling and farming links(collec of web pages that all interlink with one anther)

• What jquery - end function will do?

• What is the meaning of $ in jquery and syntax?

• Mysql engines and difference

MyISAM-default,no transaction secure,fast,hard to rebuild aftercrash(uses update table)InnoDB-secure transaction,slow,easy to rebuild after crash(uses logfiles),supports foreign key referential integrity.ND(mysql cluster)-no foreign keyCSV table-stores data in the form of CSV files

• What is indexing and how it works?

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 7/14

Indexing is a way of sorting a number of records on multiple fields. Creating an indexon a field in a table creates another data structure which holds the field value, andpointer to the record it relates to. This index structure is then sorted, allowing BinarySearches to be performed on it.->requires addition space and hence it slows the performance.Give ex of userid 4bytes,firtsname-50.lastname-50,email-100 bytes

If created index,firstname-50,indexpointer-4 bytes

• How css is parsing in the browser?Ans:Browser has a rendering engine which parses html and css,cssparser uses lexical grammer or syntax.Ex webkit(crome renderingengine)creates Stylesheetobjects

 • What is DTD (types) and why we are declaring in the first line?

• What is memcache and how to implement?

"memcached is a high-performance, distributed memory object caching system,

generic in nature, but intended for use in speeding up dynamic web applications byalleviating database load." In plain English, this means memcached is an applicationthat you can use to take advantage of spare free memory on any number of machinesto cache pretty much anything you want (with a few exceptions) and retrieve it veryquickly.

INSTALL: using the 'pecl' command: [pecl install memcache] this will download,compile, and install the extension. All you will need to do is add the line

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 8/14

'extension=memcache.so' to your php.ini file. You may also need to find and move thememcache.so file into the extensions/ directory (usually located at/usr/local/lib/php/extensions) by hand

1. IMPLEMENT: $memcache = new Memcache;

2. $memcache->connect('localhost', 11211) or die ("Could not connect");

3. function get_foo(int userid) {

4. result = db_select("SELECT * FROM users WHERE userid = ?",

userid);

5. return result;

6. }

7. After conversion to Memcached, the same call might look like the following

8. function get_foo(int userid) {

9. /* first try the cache */ 

10. data = memcached_fetch("userrow:" + userid);

11. if (!data) {12. /* not found : request database */ 

13. data = db_select("SELECT * FROM users WHERE userid = ?",

userid);

14. /* then store in cache until next get */ 

15. memcached_add("userrow:" + userid, data);

16. }

17. return data;

18. }

• What is happening after i enter desitara.com in the brower address bar?Roughly,

1. The browser resolves the URI* to an IP address.

->when you type the address, the browser sets off a DNS query for the address. (This will do a

usual lookup - cache, hostfile then server.)Next, the dns returns the answer.

2. The browser sends a GET request to that IP.

->browser sends of a http request to the ip address of the server, with the host header of 

the address you are trying to reach and various other headers and information.

3. The server finds the correct file.

4. The server processes the file.

5. The file is sent to you.

Differences:1. include & require2. die & exit

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 9/14

Ans:They are same

3. strings in single & double quotesAns:double quoted strings evaluates the variables .Single quote doesn’tSingle quote is parsed faster than double.Double quote interprets more escape characters \n,\t

4. == & ===5. get, post & request

Ans:request is associate array of get,post and cookies

6. htmlentities&htmlspecialcharsAns:htmlentities same as htmlspecialchars,except it converts all thehtml entiites special chars are just(<,>&,’,””)

7. echo & printecho is statement to print output on to screen,print same but returnsvalue.echo has multiple parameters and print only one.echo is fasterthan print.

8. split & explodeAns:split is deprecated.it splits string using regular exp intoarray.explode splits string by string)

Definitions:1. Ob_start

Ans: ob_start — Turn on output buffering

bool ob_start ([ callback $output_callback [, int $chunk_size = 0 [, bool $erase =

true ]]] )

This function will turn output buffering on. While output buffering is active nooutput is sent from the script (other than headers), instead the output is stored in

an internal buffer.

2. Debugging tools in PHPAns:DBGXDebugZendDebuggerGubed

3. Session functions

Ans:session_start()Session_id()Session_unset()Session_destroy()

4. Memcached

5. Encryption AlgorithmsAns:hash algo-sha1,sha256,md5

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 10/14

6. What is object cloningAns: Creating a copy of an object with fully replicatedproperties.Ex:crearing same window using GTK Apis

7. What is Polymorphism, interface, Abstract in PHP and write an example

Ans: Polymorphism describes a pattern in object oriented programming in which classeshave different functionality while sharing a common interface.

 An integral part of polymorphism is the common interface. There are two ways todefine an interface in PHP:interfaces and abstract classes. Both have their 

uses, and you can mix and match them as you see fit in your class hierarchy

INTERFACE: An interface is similar to a class except that it cannot contain code.

An interface can define method names and arguments, but not the contents of 

the methods. Any classes implementing an interface mustimplement all

methods defined by the interface. A class can implement multiple interfaces.

An interface is declared using the ‘interface‘ keyword:

1. interface MyInterface {

2.   public function doThis();

3.   public function doThat();

4.   public function setName($name);5. }

6.class MyClass implements MyInterface {

7.  protected $name;

8.  public function doThis() {

9.  // code that does this 10. }

11.  public function doThat() {

12.   // code that does that 13. }

14.   public function setName($name) {

15. $this->name = $name;16. }17. }

ABSTRACT: An abstract class is a mix between an interface and a class. It can definefunctionality as well as interface (in the form of abstract methods). Classes extendingan abstract class must implement all of the abstract methods defined in the abstract

class.

1. abstract class MyAbstract {

2.   public $name;

3.   public function doThis() {

4.   // do this 5. }

6.   abstract public function doThat();

7.   abstract public function setName($name);8. }

and is attached to a class using the ‘extends‘ keyword:view plaincopy to clipboard print ? 

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 11/14

1. class MyClass extends MyAbstract {

2.   // class methods 3. }

what is magic methods and usage and when each methods will call8. magic constants9. opcode cache10.memcache11.load balancing12.Have you used any tool for unit testing (php,mysql)13.How to debug php error14.How to debug js errors

1. Suppose in a game of fishville, there are more than one tanks,associated to particular user and each tank has some objects like fish,

plants, gravels, boats. The fish may be hungry after a fixed time if theydid not get feed properly. So fish health and hungriness may vary asgame proceeds. Boats are moving entity so need to track location. Nowdesign the program architecture.

2. You are given an array of 10 objects, those have methods to get objectpriority. Now objective is to get top 4 highest objects(sorted) with theirpriorities in descending order.e.g.obj1 ---1000 prority 10

obj2---- 1200 priority 8obj3-----800 priority 9obj4-----500 priority 10-------------------------------------------------------

Now in the above 4 objects output should be 1=>obj1, 2=>obj4,3=>obj3, 4=>obj2

• Difference between indexed and associative arrays.

• Difference between require and include.

• Difference between mysql_fetch_array and mysql_fetch_object.•

What are the differences between object-oriented programming in PHPand other languages like Java.

• Autoloading Objects.• Backwards compatibility of constructor method for classes (__construct

and old-style constructor function).

• Object serialization, Object cloning.• About static members and methods in a class.

• How to debug PHP code.

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 12/14

• PHP debugging and development tools.

• Asked about facebook development experience.

• Zynga Telephonic Interview

• 1. Basics of How internet works? What will happen if we type www.zynga.com in

 browser 

• 2. What are the values passed in header?• 3. About caching Mechanism

• 4. About Memcached

• 5. About logging Mechanism? How did you handled logging in ur project?

• 6. Security

• 7. XSS

• 8. Session Fixation

• 9. CSS

• 10. Dynamic creation of HTML elements using Javascript

• 11. Dynamic CSS using Javascript

12. AJAX•

• Then with the answer which I gave, he asked questions

• Practical

• Create PHP Editor 

• 1. Edit, create, view file

• 2. Flowchart was given

• 3. Internet is provided

• Technical Round after done with the pratical

• 1. Related to the code which I have done

• 2. Security, and is the security handled in my code?

• 3. About AJAX and errror handling in AJAX

• 4. Cross Domain Javascript calls

• 5. MySQL queries [Situational]

• 6. Many Situational and scenario based questions

• Then the questions continued with my answers•

• Manager Round

• 1. He told about Zynga and the way they are working

• 2. He asked about the way how I am currently working

• 3. Roles and responsibilities

• 4. Talked more about SCRUM methodology

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 13/14

• 5. Had general talk about the project

Interview Questions ( Yahoo!) - LAMP

HTML

1. what is the difference between GET and POST Method ? What will happen if we

use the GET method everywhere instead of POST?

2. what is the difference between block level and inline element?3. how to Place 3 div next to each other in a single line and the 4th div beneath the 3

divs.

4. difference between session and cookie?

5. why and what will happen if we do not sign off and close our hotmail mailboxwindow and then someone comes and open hotmail.com?

6. what will happen if we do not sign off and open another tab with the same? Same in

case of a separate browser window?7. Describe the flow from the moment we type mail.yahoo.com and we see the inbox?

8. what is the flow in struts? Like Q6 but in struts.

9. what is cross site scripting? Is there any security issue with this?if yes what andhow to resolve that?

10. what is MVC architecture? Explain one of your project if you had that architecture?

Some more questions related to them.

11. how will the webserver know which message you have clicked for the specific user 

in mail inbox?12. Explain DOCType. How do you use it? Why we should use DOCTYPE?

13. How do you design a layout?14. Why DIv is faster than tables?

CSS

What is postion and its properties?

Differentiate absolute and fixed?

JavaScript and Ajax

How ajax works?How do you highlight a particular option in the combo box?In how many ways can you get the value of html elements in a web page

XMLHTTPObject properties and methods

PHP

Can we pass special characters through URL? How will you do?

mb_string functions

7/31/2019 Phone Screen Lamp)

http://slidepdf.com/reader/full/phone-screen-lamp 14/14

How do you wrap unicode strings?

Smarty.

How to implement caching?

How do you handle internationalization through smarty?