<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>YourSearchBuddy &#187; Interview</title>
	<atom:link href="http://www.yoursearchbuddy.com/category/interview/feed" rel="self" type="application/rss+xml" />
	<link>http://www.yoursearchbuddy.com</link>
	<description>your search ends here</description>
	<lastBuildDate>Tue, 31 Jan 2012 19:47:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Program to find Anagrams</title>
		<link>http://www.yoursearchbuddy.com/program-to-find-anagram</link>
		<comments>http://www.yoursearchbuddy.com/program-to-find-anagram#comments</comments>
		<pubDate>Tue, 20 Dec 2011 22:32:05 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[How to?]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[puzzle]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[TipnTricks]]></category>
		<category><![CDATA[anagram]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[c++ anagram finder]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=6886</guid>
		<description><![CDATA[An anagram of a word or phrase is the result of rearranging its letters to form another meaningful word or phrase. For example, an anagram of “anagram finder” is “garden... <a class="meta-more" href="http://www.yoursearchbuddy.com/program-to-find-anagram">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>An anagram of a word or phrase is the result of rearranging its letters to form another meaningful word or phrase. For example, an anagram of “anagram finder” is “garden in a farm”</p>
<p>Here is a program that will find if a word is anagram of other or not.</p>
<pre>
public static boolean isAnagram(String str1, String str2) {
	char[] str1_chars = str1.toCharArray();
	char[] str2_chars = str2.toCharArray();
	HashMap<character , Integer> str1_map = new HashMap</character><character , Integer>();
	for (Character c : str1_chars) {
		if (!str1_map.containsKey(c)) {
			str1_map.put(c, 1);
		} else {
			str1_map.put(c, str1_map.get(c) + 1);
		}
	}
	HashMap</character><character , Integer> str2_map = new HashMap</character><character , Integer>();
	for (Character c : str2_chars) {
		if (!str2_map.containsKey(c)) {
			str2_map.put(c, 1);
		} else {
			str2_map.put(c, str2_map.get(c) + 1);
		}
	}
	if (str1_map.size() != str2_map.size()) {
		return false;
	} else {
		for (Character c : str2_map.keySet()) {
			if (str1_map.containsKey(c) &#038;&#038; (str1_map.get(c) == str2_map.get(c))) {
				continue;
			} else {
				return false;
			}
		}
		return true;
	}
}
</character></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/program-to-find-anagram/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium Interview Questions</title>
		<link>http://www.yoursearchbuddy.com/selenium-interview-questions</link>
		<comments>http://www.yoursearchbuddy.com/selenium-interview-questions#comments</comments>
		<pubDate>Mon, 09 May 2011 19:48:30 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Interview]]></category>
		<category><![CDATA[select duplicate]]></category>
		<category><![CDATA[Selenium IDE]]></category>
		<category><![CDATA[Selenium Interview Questions]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=4700</guid>
		<description><![CDATA[Selenium is a portable software testing framework for web applications. The tests can be written as HTML tables or coded in a number of popular programming languages and can be... <a class="meta-more" href="http://www.yoursearchbuddy.com/selenium-interview-questions">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Selenium is a portable software testing framework for web applications. The tests can be written as HTML tables or coded in a number of popular programming languages and can be run directly in most modern web browsers. Selenium can be deployed on Windows, Linux, and Macintosh. Selenium is used for UAT (User Acceptance Test).</p>
<p><strong>Selenium consists of</strong>: </p>
<p>- Selenium Core<br />
- Selenium RC<br />
- Selenium Grid<br />
- Selenium on Rails<br />
- Selenium IDE</p>
<p> <strong>Selenium IDE</strong>:</p>
<p>Selenium IDE is a complete Integrated Development Environment (IDE) for Selenium tests (previously known as Selenium Recorder). Firefox extension that allows recording and editing of tests. It allows easier development of tests. It can output Ruby for it’s Ruby based (Application Programming Interface) API.</p>
<p> <strong>Selenium IDE Features</strong>:</p>
<p>- Record and playback<br />
- Intelligent field selection will use IDs, names, or XPath as needed<br />
- Auto complete for all common Selenium commands<br />
- Walk through test cases and test suites.<br />
- Debug and set breakpoints<br />
- Save tests as HTML, Ruby scripts, or other formats<br />
- Support for Selenium user-extensions.js file<br />
- Option to automatically assert the title of every page<br />
- Rollup common commands </p>
<p><strong>Selenium Interview Questions</strong>: </p>
<p><strong>Q1. What is Selenium?</strong></p>
<p><strong>Ans.</strong> Selenium is a set of tools that supports rapid development of test automation scripts for web based applications. Selenium testing tools provides a rich set of testing functions specifically designed to fulfill needs of testing of a web based application.</p>
<p> <strong>Q2. What are the main components of Selenium testing tools?</strong><br />
<strong>Ans.</strong> Selenium IDE, Selenium RC and Selenium Grid</p>
<p> <strong>Q3. What is Selenium IDE?</strong><br />
<strong>Ans.</strong> Selenium IDE is for building Selenium test cases. It operates as a Mozilla Firefox add on and provides an easy to use interface for developing and running individual test cases or entire test suites. Selenium-IDE has a recording feature, which will keep account of user actions as they are performed and store them as a reusable script to play back.</p>
<p> <strong>Q4. What is the use of context menu in Selenium IDE?</strong><br />
<strong>Ans.</strong> It allows the user to pick from a list of assertions and verifications for the selected location.</p>
<p><strong>Q5. Can tests recorded using Selenium IDE be run in other browsers?</strong><br />
<strong>Ans.</strong> Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be run in other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the test suite in command line.</p>
<p> <strong>Q6. What are the advantage and features of Selenium IDE?</strong></p>
<p><strong>Ans: 1.</strong> Intelligent field selection will use IDs, names, or XPath as needed<br />
<strong>2.</strong> It is a record &#038; playback tool and the script format can be written in various languages including C#, Java, PERL, Python, PHP, HTML<br />
<strong>3.</strong> Auto complete for all common Selenium commands<br />
<strong>4.</strong> Debug and set breakpoints<br />
<strong>5.</strong> Option to automatically assert the title of every page<br />
<strong>6.</strong> Support for Selenium user-extensions.js file</p>
<p><strong>Q7. What are the disadvantage of Selenium IDE tool?</strong><br />
<strong>Ans: 1.</strong> Selenium IDE tool can only be used in Mozilla Firefox browser.<br />
<strong>2.</strong> It is not playing multiple windows when we record it.</p>
<p><strong>Q8. What is Selenium RC (Remote Control)?</strong><br />
<strong>Ans.</strong> Selenium RC allows the test automation expert to use a programming language for maximum flexibility and extensibility in developing test logic. For example, if the application under test returns a result set and the automated test program needs to run tests on each element in the result set, the iteration / loop support of programming language’s can be used to iterate through the result set, calling Selenium commands to run tests on each item.</p>
<p>Selenium RC provides an API and library for each of its supported languages. This ability to use Selenium RC with a high level programming language to develop test cases also allows the automated testing to be integrated with the project’s automated build environment.</p>
<p> <strong>Q9. What is Selenium Grid?</strong></p>
<p><strong>Ans.</strong> Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for test suites that must be run in multiple environments. Selenium Grid can be used to run multiple instances of Selenium RC on various operating system and browser configurations.</p>
<p><strong>Q10. How Selenium Grid works?</strong></p>
<p><strong>Ans.</strong> Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC, which launch the browser and run the test. Thus, it allows for running tests in parallel with the entire test suite.</p>
<p><strong>Q 11. What you say about the flexibility of Selenium test suite?</strong><br />
<strong>Ans.</strong> Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, it is Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred programming or scripting language of one’s choice.</p>
<p>Also, the Selenium testing suite is an open source project where code can be modified and enhancements can be submitted for contribution.</p>
<p><strong>Q12. What test can Selenium do?</strong><br />
<strong>Ans.</strong> Selenium is basically used for the functional testing of web based applications. It can be used for testing in the continuous integration environment. It is also useful for agile testing</p>
<p><strong>Q13. What is the cost of Selenium test suite?</strong><br />
<strong>Ans.</strong> Selenium test suite a set of open source software tool, it is free of cost.</p>
<p><strong>Q14. What browsers are supported by Selenium Remote Control?</strong><br />
<strong>Ans.</strong> The test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to run tests in Selenium Remote Control.</p>
<p><strong>Q15. What programming languages can you use in Selenium RC?</strong><br />
<strong>Ans.</strong> C#, Java, Perl, PHP, Python, Ruby</p>
<p><strong>Q16. What are the advantages and disadvantages of using Selenium as testing tool?</strong><br />
<strong>Ans.</strong> Advantages: Free, Simple and powerful DOM (document object model) level testing, can be used for continuous integration; great fit with Agile projects.</p>
<p><strong>Disadvantages:</strong> Tricky setup; dreary errors diagnosis; can not test client server applications.</p>
<p><strong>Q17. What is difference between QTP and Selenium?</strong><br />
<strong>Ans.</strong> Only web applications can be testing using Selenium testing suite. However, QTP can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, QTP is limited to Internet Explorer on Windows.</p>
<p>QTP uses scripting language implemented on top of VB Script. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.</p>
<p><strong>Q18. What is difference between Borland Silk test and Selenium?</strong><br />
<strong>Ans.</strong> Selenium is completely free test automation tool, while Silk Test is not. Only web applications can be testing using Selenium testing suite. However, Silk Test can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, Silk Test is limited to Internet Explorer and Firefox.</p>
<p>Silk Test uses 4Test scripting language. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/selenium-interview-questions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic shell scripting questions</title>
		<link>http://www.yoursearchbuddy.com/basic-shell-scripting-questions</link>
		<comments>http://www.yoursearchbuddy.com/basic-shell-scripting-questions#comments</comments>
		<pubDate>Mon, 14 Feb 2011 21:23:40 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Interview]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[shell scripting questions]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=3205</guid>
		<description><![CDATA[1. How do you find out what’s your shell? &#8211; echo $SHELL 2. What’s the command to find out today’s date? &#8211; date 3. What’s the command to find out... <a class="meta-more" href="http://www.yoursearchbuddy.com/basic-shell-scripting-questions">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>  <strong> 1. How do you find out what’s your shell?</strong> &#8211; echo $SHELL</p>
<p>   <strong>2. What’s the command to find out today’s date?</strong> &#8211; date</p>
<p>   <strong>3. What’s the command to find out users on the system?</strong> &#8211; who</p>
<p>   <strong>4. How do you find out the current directory you’re in?</strong> &#8211; pwd</p>
<p>  <strong> 5. How do you remove a file?</strong> &#8211; rm</p>
<p>   <strong>6. How do you remove a</strong> &#8211; rm -rf</p>
<p>   <strong>7. How do you find out your own username?</strong> &#8211; whoami</p>
<p>   <strong>8. How do you send a mail message to somebody?</strong> &#8211; mail somebody@techinterviews.com -s ‘Your subject’ -c ‘cc@techinterviews.com‘</p>
<p>   <strong>9. How do you count words, lines and characters in a file?</strong> &#8211; wc</p>
<p>  <strong>10. How do you search for a string inside a given file?</strong> &#8211; grep string filename</p>
<p>  <strong>11. How do you search for a string inside a directory?</strong> &#8211; grep string *</p>
<p>  <strong>12. How do you search for a string in a directory with the subdirectories recursed?</strong> &#8211; grep -r string *</p>
<p>  <strong>13. What are PIDs?</strong> &#8211; They are process IDs given to processes. A PID can vary from 0 to 65535.</p>
<p>  <strong>14. How do you list currently running process?</strong> &#8211; ps</p>
<p>  <strong>15. How do you stop a process?</strong> &#8211; kill pid</p>
<p>  <strong>16. How do you find out about all running processes?</strong> &#8211; ps -ag</p>
<p>  <strong>17. How do you stop all the processes, except the shell window?</strong> &#8211; kill 0</p>
<p>  <strong>18. How do you fire a process in the background?</strong> &#8211; ./process-name &#038;</p>
<p>  <strong>19. How do you refer to the arguments passed to a shell script?</strong> &#8211; $1, $2 and so on. $0 is your script name.</p>
<p>  <strong>20. What’s the conditional statement in shell scripting?</strong> &#8211; if {condition} then … fi</p>
<p>  <strong>21. How do you do number comparison in shell scripts?</strong> &#8211; -eq, -ne, -lt, -le, -gt, -ge</p>
<p>  <strong>22. How do you test for file properties in shell scripts?</strong> &#8211; -s filename tells you if the file is not empty, -f filename tells you whether the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for executability</p>
<p>  <strong>23. How do you do Boolean logic operators in shell scripting?</strong> &#8211; ! tests for logical not, -a tests for logical and, and -o tests for logical or.</p>
<p>  <strong>24. How do you find out the number of arguments passed to the shell script?</strong> &#8211; $#</p>
<p>  <strong>25. What’s a way to do multilevel if-else’s in shell scripting?</strong> &#8211; if {condition} then {statement} elif {condition} {statement} fi</p>
<p>  <strong>26. How do you write a for loop in shell?</strong> &#8211; for {variable name} in {list} do {statement} done</p>
<p>  <strong>27. How do you write a while loop in shell?</strong> &#8211; while {condition} do {statement} done</p>
<p> <strong> 28. How does a case statement look in shell scripts?</strong> &#8211; case {variable} in {possible-value-1}) {statement};; {possible-value-2}) {statement};; esac</p>
<p>  <strong>29. How do you read keyboard input in shell scripts?</strong> &#8211; read {variable-name}</p>
<p>  <strong>30. How do you define a function in a shell script?</strong> &#8211; function-name() { #some code here return }</p>
<p>  <strong>31. How does getopts command work?</strong> &#8211; The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/basic-shell-scripting-questions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logical Interview Questions</title>
		<link>http://www.yoursearchbuddy.com/logical-interview-questions</link>
		<comments>http://www.yoursearchbuddy.com/logical-interview-questions#comments</comments>
		<pubDate>Tue, 18 Jan 2011 22:22:32 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Interview]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Interview Questions]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=2513</guid>
		<description><![CDATA[# Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal... <a class="meta-more" href="http://www.yoursearchbuddy.com/logical-interview-questions">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p># Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife ?</p>
<p>The cut (plane) should pass through the center of the two rectangles: the outer cake and the inner hollow area. Since any plane passing through the center of the cuboid will divide the volume in two halves, both the cake and hollow area are divided into two equal halves.</p>
<p># Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.</p>
<p>Many solutions: Bit vector, sorting&#8230;</p>
<p># How many points are there on the globe where by walking one mile south, one mile east and one mile north you reach the place where you started.</p>
<p>The answer is &#8220;many points&#8221;. The set of such points is given as {North pole, special circle}.</p>
<p>From north pole, walking one mile south followed by one mile east still keeps you one mile south of North pole.</p>
<p>The special circle consists of a set of points defined as follows. Let&#8217;s say you were to locate a spot near the South Pole where the circular distance &#8220;around&#8221; the Earth&#8217;s North-South axis is 1 mile. The path of such a journey would create a circle with a radius of approximately 840.8 feet (because C=2.r.pi). Call this point X. Now consider another point Y one mile north of X. The special circle is the circular path around North-South axis going through Y. If you begin you journey from any point (say Y1) on this special circle, and travel one mile south, you get to a point (say X1) on the circle of point X. Now one mile east will bring you back to X1, because circumference of circle of X is 1 mile. Then one mile North brings you back to Y1. (Answer supplied by Kristie Boman)</p>
<p># In a X&#8217;s and 0&#8242;s game (i.e. TIC TAC TOE) if you write a program for this give a fast way to generate the moves by the computer. I mean this should be the fastest way possible.</p>
<p>The answer is that you need to store all possible configurations of the board and the move that is associated with that. Then it boils down to just accessing the right element and getting the corresponding move for it. Do some analysis and do some more optimization in storage since otherwise it becomes infeasible to get the required storage in a DOS machine.</p>
<p># There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner.. what is the probability that they don&#8217;t collide.</p>
<p>All three should move in the same direction &#8211; clockwise or anticlockwise. Probability is 1/4.</p>
<p># There are 4 men who want to cross a bridge. They all begin on the same side. You have 17 minutes to get all of them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each man walks at a different speed. A pair must walk together at the rate of the slower mans pace.</p>
<p>Man 1:1 minute to cross<br />
Man 2: 2 minutes to cross<br />
Man 3: 5 minutes to cross<br />
Man 4: 10 minutes to cross</p>
<p>1 and 2 cross together. 1 comes back. then 3 and 4 cross. 2 comes back. then 1 and 2 cross. Total time is 2+1+10+2+2 = 17.</p>
<p># You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?</p>
<p>Take one pill from first, two from second, three from third and so on. Total pills are n(n+1)/2 and should weigh 10n(n+1)/2. If it weighs x gm less than that then the x&#8217;th jar is contaminated, since we took x pills from that jar which weighed 1 gm less.</p>
<p># One train leaves Los Angeles at 15 MPH heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they collide, how far will the bird have traveled?</p>
<p>If distance is X miles between NY and LA, then it takes X/(15+20) hours for the trains to collide, and bird will have travelled 25X/(15+20) = 5X/7 miles in that time.</p>
<p># Imagine that you have 26 constants, labelled A through Z. Each constant is assigned a value in the following way: A = 1; the rest of the values equal their position in the alphabet (B corresponds to the second position so it equals 2, C = 3, etc.) raised to the power of the preceeding constant value. So, B = 2 ^ (A&#8217;s value), or B = 2^1 = 2. C = 3^2 = 9. D = 4^9, etc., etc. Find the exact numerical value to the following equation:</p>
<p>(X &#8211; A) * (X &#8211; B) * (X &#8211; C) * &#8230; * (X &#8211; Y) * (X &#8211; Z) </p>
<p>Answer is 0, because (X-X) is present in the product.</p>
<p># You have 12 balls. All of them are identical except one, which is either heavier or lighter than the rest &#8211; it is either hollow while the rest are solid, or solid while the rest are hollow. You have a simple two-armed scale, and are permitted three weighings. Can you identify the odd ball, and determine whether it is hollow or solid.</p>
<p>Let the balls be numbered 1 to 12. Firstly, put 1-4 on one side and 5-8 on other side. If both are equal then one of 9-12 is odd. Then second try, weigh 9-10 vs 1-2, if equal, one of 11-12 is bad, else 9-10 is bad. Testing which one is bad can be done by (third try) weighing 11 or 9, respectively, with good ball 1. It also gives whether the odd ball is heavy or light.<br />
Programming questions that require thinking</p>
<p># Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.</p>
<p>The basic idea is to draw one quadrant and replicate it to other four quadrants. Assuming the center is given as (x,y) and radius as r units, then start X from (x+r) down to (x) and start Y from y up to (y+r). In the iteration, keep comparing is the equation is satisfied or not within an error of one unit for x and y. If not then re-adjust X and Y.</p>
<p># Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.</p>
<p>void putlong(unsigned long x)<br />
{<br />
	// we know that 32 bits can have 10 digits. 2^32 = 4294967296<br />
	for (unsigned long y = 1000000000; y > 0; y /= 10) {<br />
		putchar( (x / y) + &#8217;0&#8242;);<br />
		x = x % y;<br />
	}<br />
}</p>
<p># Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]</p>
<p>if (x &#038;&#038; !(x &#038; (x-1)) == 0)</p>
<p># What are the different ways to say, the value of x can be either a 0 or a 1.</p>
<p>Apparently the if then else solution has a jump when written out in assembly.</p>
<p>if (x == 0)<br />
	y=0<br />
else<br />
	y =x</p>
<p>There is a logical, arithmetic and a datastructure soln to the above problem.</p>
<p># I was given two lines of assembly code which found the absolute value of a number stored in two&#8217;s complement form. I had to recognize what the code was doing.</p>
<p>Pretty simple if you know some assembly and some fundaes on number representation.</p>
<p># Give a fast way to multiply a number by 7.</p>
<p>Multiply by 8 (left shift by 3 bits) and then subtract the number.</p>
<p>(x < < 3) - x</p>
<p># Write a function that returns the factorial of a number.</p>
<p>This is a typical, can-you-program warm-up question. Example 1 shows the iterative and recursive solutions. Notice that in both solutions, I check the input values and boundary conditions. Factorials of negative numbers are undefined, and the factorial of both 0 and 1 are 1. The functions in Example 1 handle these cases correctly, and they initialize all variables.</p>
<p># Write a function that computes the nth number in the Fibonacci sequence.</p>
<p>Example 2 contains both the iterative and recursive solutions. The iterative version maintains variables to hold the last two values in the Fibonacci sequence, and uses them to compute the next value. Again, boundary conditions and inputs are checked. The 0th number in the Fibonacci sequence is defined as 0. The first number in the sequence is 1. Return -1 if a negative number is passed.</p>
<p>The recursive version of the Fibonacci function works correctly, but is considerably more expensive than the iterative version. There are, however, other ways to write this function recursively in C that are not as expensive. For instance, you could maintain static variables or create a struct to hold previously computed results.</p>
<p># Write an implementation of strlen().</p>
<p>Given a char pointer, strlen() determines the number of chars in a string. The first thing that your strlen() implementation ought to do is to check your boundary conditions. Don't forget the case where the pointer you are given is pointing to an empty string. What about the case where the pointer is equal to NULL? This is a case where you should state your assumptions. In many implementations, the real strlen() doesn't check to see if the pointer is NULL, so passing a NULL pointer to strlen() would result in a segmentation fault. Making it clear to your interviewer that you are aware of both of these boundary conditions shows that you understand the problem and that you have thought about its solution carefully. Example 3 shows the correct solution.</p>
<p># Switch the integer values stored in two registers without using any additional memory.</p>
<p>To swap the values, you can carry out the following instructions:</p>
<p>Reg_1 = Reg_1 + Reg_2;<br />
Reg_2 = Reg_1 - Reg_2;<br />
Reg_1 = Reg_1 - Reg_2;</p>
<p># Write code for reversing a linked list.</p>
<p>NodePtr reversed=NULL, cur=head;<br />
while(cur!=NULL)<br />
{<br />
      //detach cur<br />
      head=head->next;<br />
      //link cur to reversed list<br />
      cur->next=reversed;<br />
      reversed=cur;<br />
      //move cur to next node<br />
      cur=head;<br />
}<br />
head=reversed;</p>
<p># Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).</p>
<p>int main()<br />
{<br />
	int a[10]={1, 2, 4, 4, 7, 8, 9, 14, 14, 20};<br />
	int i;<br />
	for (i = 0;i&lt;9;i++)<br />
	{<br />
		if (a[i] != a[i+1])<br />
		printf(&#8220;%d\n&#8221;,a[i]);<br />
	}<br />
	return 0;<br />
}</p>
<p># Write an algorithm to detect loop in a linked list.</p>
<p>You are presented with a linked list, which may have a &#8220;loop&#8221; in it. That is, an element of the linked list may incorrectly point to a previously encountered element, which can cause an infinite loop when traversing the list. Devise an algorithm to detect whether a loop exists in a linked list. How does your answer change if you cannot change the structure of the list elements?</p>
<p>One possible answer is to add a flag to each element of the list. You could then traverse the list, starting at the head and tagging each element as you encounter it. If you ever encountered an element that was already tagged, you would know that you had already visited it and that there existed a loop in the linked list. What if you are not allowed to alter the structure of the elements of the linked list? The following algorithm will find the loop:</p>
<p>   1. Start with two pointers ptr1 and ptr2.<br />
   2. Set ptr1 and ptr2 to the head of the linked list.<br />
   3. Traverse the linked list with ptr1 moving twice as fast as ptr2 (for every two elements that ptr1 advances within the list, advance ptr2 by one element).<br />
   4. Stop when ptr1 reaches the end of the list, or when ptr1 = ptr2.<br />
   5. If ptr1 and ptr2 are ever equal, then there must be a loop in the linked list. If the linked list has no loops, ptr1 should reach the end of the linked list ahead of ptr2. </p>
<p># Given the time, devise an algorithm to calculate the angle between the hour and minute hands of an analog clock.</p>
<p>The important realization for this problem is that the hour hand is always moving. In other words, at 1:30, the hour hand is halfway between 1 and 2. Once you remember that, this problem is fairly straightforward. Assuming you don&#8217;t care whether the function returns the shorter or larger angle, Example 4 shows a solution to this problem. </p>
<p># Devise an algorithm for detecting whether a given string is a palindrome (spelled the same way forwards and backwards). For example, &#8220;A man, a plan, a canal, Panama.&#8221;</p>
<p>For the sake of this problem, assume that the string has been stripped of punctuation (including spaces), and has been converted to a single case. The most efficient way to detect whether a string is a palindrome is to create two pointers. Set one at the beginning of the string, and one at the end. Compare the values at those locations. If the values don&#8217;t match, the string isn&#8217;t a palindrome. Otherwise, move each pointer inward and repeat the comparison. Stop when the pointers are pointing to the same position in the string (if its length is an odd-number) or when the pointers have &#8220;crossed&#8221; (if the string&#8217;s length is an even-number). Example 5 shows the correct solution. </p>
<p># Given an eight-bit bitmap graphics file, devise an algorithm to convert the file into a two-bit ASCII approximation.</p>
<p>Assume that the file format is one byte for every pixel in the file, and that the approximation will produce one ASCII character of output for each pixel. This problem is easier to solve than it sounds. This is one of the tricks used in technical interview questions. Problems may be obscured or made to sound difficult. Don&#8217;t be fooled! Take the time to think about the core of the problem. In this case, all you want is an algorithm for reading the values in a file and outputting characters based upon those values.</p>
<p>Eight-bit numbers can be in the range from 0 to 255. Two-bit numbers are in the range from 0 to 3. Basically, we want to divide the 256 numbers specified by an eight-bit number into four ranges, which can be indicated by a two-bit number. So, divide the range of 0 to 255 uniformly into four separate ranges: 0 to 63, 64 to 127, 128 to 191, and 192 to 255.</p>
<p>You then have to assign an ASCII character to each of those four ranges of numbers. For example, you could use &#8220;_&#8221;, &#8220;~&#8221;, &#8220;+&#8221;, and &#8220;#&#8221;. Then, the algorithm is as follows:</p>
<p>1.	Open the file.<br />
2.	For every byte in the file:<br />
a.	Read in one byte.<br />
b.	If the value is in the range 0..63, we&#8217;ll print &#8216;_&#8217;.<br />
c.	If the value is in the range 64..127, we&#8217;ll print &#8216;~&#8217;.<br />
d.	If the value is in the range 128..191, we&#8217;ll print &#8216;+&#8217;.<br />
e.	If the value is in the range 192..255, we&#8217;ll print &#8216;#&#8217;.<br />
3.	Close the file.</p>
<p># Increment the variable next three different ways.</p>
<p>next = next + 1;<br />
and<br />
next++;<br />
and<br />
next += 1;</p>
<p># Specify the skeletons of two C loops with the test at the top.</p>
<p>next = 0; /* setup */</p>
<p>while ( next < max) { /* test */ printf(&#8220;Hello &#8220;); /* body */ next++; /* update */ }</p>
<p>and</p>
<p>for ( next = 0; next < max; next++) /* setup,test */ /* and update */ printf(&#8220;Hello&#8221;); /* body */ </p>
<p># What does the following fragment do?</p>
<p>while((d=c=getch(),d)!=EOF&#038;&#038;(c!=&#8217;\t&#8217;||c!=&#8217; &#8216;||c!=&#8217;\b&#8217;)) *buff++ = ++c; </p>
<p>Do the following until either the end of standard input or the variable c takes on the value of a tab, space, or backspace character: Store the character that succeeds the character stored in c into the current location pointed by buff. Then increment buff to point to the next location in memory. Meanwhile, d is assigned the same value as c and it is the value of d that is used in the comparison to EOF. </p>
<p># Write an efficient C code for &#8216;tr&#8217; program. &#8216;tr&#8217; has two command line arguments. They both are strings of same length. tr reads an input file, replaces each character in the first string with the corresponding character in the second string. eg. &#8216;tr abc xyz&#8217; replaces all &#8216;a&#8217;s by &#8216;x&#8217;s, &#8216;b&#8217;s by &#8216;y&#8217;s and so on.</p>
<p>have an array of length 26.<br />
put &#8216;x&#8217; in array element corr to &#8216;a&#8217;<br />
put &#8216;y&#8217; in array element corr to &#8216;b&#8217;<br />
put &#8216;z&#8217; in array element corr to &#8216;c&#8217;<br />
put &#8216;d&#8217; in array element corr to &#8216;d&#8217;<br />
put &#8216;e&#8217; in array element corr to &#8216;e&#8217;<br />
and so on.</p>
<p>the code</p>
<p>while (!eof)<br />
{<br />
c = getc();<br />
putc(array[/c]);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/logical-interview-questions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One line C function to find if a no is power of 2</title>
		<link>http://www.yoursearchbuddy.com/line-function-find-power-2</link>
		<comments>http://www.yoursearchbuddy.com/line-function-find-power-2#comments</comments>
		<pubDate>Fri, 14 Jan 2011 20:18:33 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[How to?]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=2504</guid>
		<description><![CDATA[Subtract a power of 2 numbers by 1 then all unset bits after the only set bit become set; and the set bit become unset. For example for 4 (... <a class="meta-more" href="http://www.yoursearchbuddy.com/line-function-find-power-2">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Subtract a power of 2 numbers by 1 then all unset bits after the only set bit become set; and the set bit become unset.</p>
<p>For example for 4 ( 100) and 16(10000), we get following after subtracting 1<br />
3 –> 011<br />
15 –> 01111</p>
<p>So, if a number n is a power of 2 then bitwise &#038; of n and n-1 will be zero. We can say n is a power of 2 or not based on value of n&#038;(n-1). The expression n&#038;(n-1) will not work when n is 0. To handle this case also, our expression will become n&#038; (!n&#038;(n-1)) .</p>
<p><strong>Below is the implementation of this method.</strong></p>
<pre>
#define bool int

<strong>/* Function to check if x is power of 2*/</strong>
bool isPowerOfTwo (int x)
{
<strong>  /* First x in the below expression is for the case when x is 0 */</strong>
  return x &#038;&#038; (!(x&#038;(x-1)));
}

<strong>/*Driver program to test above function*/</strong>
int main()
{
    int test_no = 29;
    if(isPowerOfTwo(test_no))
       printf("%d is a power of 2", test_no);
    else
       printf("%d is not a power of 2", test_no);
    getchar();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/line-function-find-power-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>50 Common Interview Questions &amp; Answers</title>
		<link>http://www.yoursearchbuddy.com/50-common-interview-questions-answers</link>
		<comments>http://www.yoursearchbuddy.com/50-common-interview-questions-answers#comments</comments>
		<pubDate>Mon, 20 Dec 2010 19:07:19 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Interview]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=2166</guid>
		<description><![CDATA[1. Tell me about yourself: The most often asked question in interviews. You need to have a short statement prepared in your mind. Be careful that it does not sound... <a class="meta-more" href="http://www.yoursearchbuddy.com/50-common-interview-questions-answers">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>1. Tell me about yourself:</strong><br />
The most often asked question in interviews. You need to have a short statement prepared in your mind. Be careful that it does not sound rehearsed. Limit it to work-related items unless instructed otherwise. Talk about things you have done and jobs you have held that relate to the position you are interviewing for. Start with the item farthest back and work up to the present.</p>
<p><strong>2. Why did you leave your last job?</strong><br />
Stay positive regardless of the circumstances. Never refer to a major problem with management and never speak ill of supervisors, co-workers or the organization. If you do, you will be the one looking bad. Keep smiling and talk about leaving for a positive reason such as an opportunity, a chance to do something special or other forward-looking reasons.</p>
<p><strong>3. What experience do you have in this field?</strong><br />
Speak about specifics that relate to the position you are applying for. If you do not have specific experience, get as close as you can.</p>
<p><strong>4. Do you consider yourself successful?</strong><br />
You should always answer yes and briefly explain why. A good explanation is that you have set goals, and you have met some and are on track to achieve the others.</p>
<p><strong>5. What do co-workers say about you?</strong><br />
Be prepared with a quote or two from co-workers. Either a specific statement or a paraphrase will work. Jill Clark, a co-worker at Smith Company, always said I was the hardest workers she had ever known. It is as powerful as Jill having said it at the interview herself.</p>
<p><strong>6. What do you know about this organization?</strong><br />
This question is one reason to do some research on the organization before the interview. Find out where they have been and where they are going. What are the current issues and who are the major players?</p>
<p><strong>7. What have you done to improve your knowledge in the last year?</strong><br />
Try to include improvement activities that relate to the job. A wide variety of activities can be mentioned as positive self-improvement. Have some good ones handy to mention.</p>
<p><strong>8. Are you applying for other jobs?</strong><br />
Be honest but do not spend a lot of time in this area. Keep the focus on this job and what you can do for this organization. Anything else is a distraction.</p>
<p><strong>9. Why do you want to work for this organization?</strong><br />
This may take some thought and certainly, should be based on the research you have done on the organization. Sincerity is extremely important here and will easily be sensed. Relate it to your long-term career goals.</p>
<p><strong>10. Do you know anyone who works for us?</strong><br />
Be aware of the policy on relatives working for the organization. This can affect your answer even though they asked about friends not relatives. Be careful to mention a friend only if they are well thought of.</p>
<p><strong>11. What kind of salary do you need?</strong><br />
A loaded question. A nasty little game that you will probably lose if you answer first. So, do not answer it. Instead, say something like, That’s a tough question. Can you tell me the range for this position?</p>
<p>In most cases, the interviewer, taken off guard, will tell you. If not, say that it can depend on the details of the job. Then give a wide range.</p>
<p><strong>12. Are you a team player?</strong><br />
You are, of course, a team player. Be sure to have examples ready. Specifics that show you often perform for the good of the team rather than for yourself are good evidence of your team attitude. Do not brag, just say it in a matter-of-fact tone. This is a key point.</p>
<p><strong>13. How long would you expect to work for us if hired?</strong><br />
Specifics here are not good. Something like this should work: I’d like it to be a long time. Or As long as we both feel I’m doing a good job.</p>
<p><strong>14. Have you ever had to fire anyone? How did you feel about that?</strong><br />
This is serious. Do not make light of it or in any way seem like you like to fire people. At the same time, you will do it when it is the right thing to do. When it comes to the organization versus the individual who has created a harmful situation, you will protect the organization. Remember firing is not the same as layoff or reduction in force.</p>
<p><strong>15. What is your philosophy towards work?</strong><br />
The interviewer is not looking for a long or flowery dissertation here. Do you have strong feelings that the job gets done? Yes. That’s the type of answer that works best here. Short and positive, showing a benefit to the organization.</p>
<p><strong>16. If you had enough money to retire right now, would you?</strong><br />
Answer yes if you would. But since you need to work, this is the type of work you prefer. Do not say yes if you do not mean it.</p>
<p><strong>17. Have you ever been asked to leave a position?</strong><br />
If you have not, say no. If you have, be honest, brief and avoid saying negative things about the people or organization involved.</p>
<p><strong>18. Explain how you would be an asset to this organization</strong><br />
You should be anxious for this question. It gives you a chance to highlight your best points as they relate to the position being discussed. Give a little advance thought to this relationship.</p>
<p><strong>19. Why should we hire you?</strong><br />
Point out how your assets meet what the organization needs. Do not mention any other candidates to make a comparison.</p>
<p><strong>20. Tell me about a suggestion you have made</strong><br />
Have a good one ready. Be sure and use a suggestion that was accepted and was then considered successful. One related to the type of work applied for is a real plus.</p>
<p><strong>21. What irritates you about co-workers?</strong><br />
This is a trap question. Think real hard but fail to come up with anything that irritates you. A short statement that you seem to get along with folks is great.</p>
<p><strong>22. What is your greatest strength?</strong><br />
Numerous answers are good, just stay positive. A few good examples:<br />
Your ability to prioritize, Your problem-solving skills, Your ability to work under pressure, Your ability to focus on projects, Your professional expertise, Your leadership skills, Your positive attitude</p>
<p><strong>23. Tell me about your dream job.</strong><br />
Stay away from a specific job. You cannot win. If you say the job you are contending for is it, you strain credibility. If you say another job is it, you plant the suspicion that you will be dissatisfied with this position if hired. The best is to stay genetic and say something like: A job where I love the work, like the people, can contribute and can’t wait to get to work.</p>
<p><strong>24. Why do you think you would do well at this job?</strong><br />
Give several reasons and include skills, experience and interest.</p>
<p><strong>25. What are you looking for in a job?</strong><br />
Very similar question 23</p>
<p><strong>26. What kind of person would you refuse to work with?</strong><br />
Do not be trivial. It would take disloyalty to the organization, violence or lawbreaking to get you to object. Minor objections will label you as a whiner.</p>
<p><strong>27. What is more important to you: the money or the work?</strong><br />
Money is always important, but the work is the most important. There is no better answer.</p>
<p><strong>28. What would your previous supervisor say your strongest point is?</strong><br />
There are numerous good possibilities:<br />
Loyalty, Energy, Positive attitude, Leadership, Team player, Expertise, Initiative, Patience, Hard work, Creativity, Problem solver</p>
<p><strong>29. Tell me about a problem you had with a supervisor</strong><br />
Biggest trap of all. This is a test to see if you will speak ill of your boss. If you fall for it and tell about a problem with a former boss, you may well below the interview right there. Stay positive and develop a poor memory about any trouble with a supervisor.</p>
<p><strong>30. What has disappointed you about a job?</strong><br />
Don’t get trivial or negative. Safe areas are few but can include:<br />
Not enough of a challenge. You were laid off in a reduction Company did not win a contract, which would have given you more responsibility.</p>
<p><strong>31. Tell me about your ability to work under pressure.</strong><br />
You may say that you thrive under certain types of pressure. Give an example that relates to the type of position applied for.</p>
<p><strong>32. Do your skills match this job or another job more closely?</strong><br />
Probably this one. Do not give fuel to the suspicion that you may want another job more than this one.</p>
<p><strong>33. What motivates you to do your best on the job?</strong><br />
This is a personal trait that only you can say, but good examples are:<br />
Challenge, Achievement, Recognition</p>
<p><strong>34. Are you willing to work overtime? Nights? Weekends?</strong><br />
This is up to you. Be totally honest because if you commit you have to. I have seen people promise to be flexible to get a job but then it really becomes hassle.</p>
<p><strong>35. How would you know you were successful on this job?</strong><br />
Several ways are good measures:<br />
You set high standards for yourself and meet them. Your outcomes are a success.Your boss tell you that you are successful</p>
<p><strong>36. Would you be willing to relocate if required?</strong><br />
You should be clear on this with your family prior to the interview if you think there is a chance it may come up. Do not say yes just to get the job if the real answer is no. This can create a lot of problems later on in your career. Be honest at this point and save yourself future grief.</p>
<p><strong>37. Are you willing to put the interests of the organization ahead of your own?</strong><br />
This is a straight loyalty and dedication question. Do not worry about the deep ethical and philosophical implications. Just say yes.</p>
<p><strong>38. Describe your management style.</strong><br />
Try to avoid labels. Some of the more common labels, like progressive, salesman or consensus, can have several meanings or descriptions depending on which management expert you listen to. The situational style is safe, because it says you will manage according to the  situation, instead of one size fits all.</p>
<p><strong>39. What have you learned from mistakes on the job?</strong><br />
Here you have to come up with something or you strain credibility. Make it small, well intentioned mistake with a positive lesson learned. An example would be working too far ahead of colleagues on a project and thus throwing coordination off.</p>
<p><strong>40. Do you have any blind spots?</strong><br />
Trick question. If you know about blind spots, they are no longer blind spots. Do not reveal any personal areas of concern here. Let them do their own discovery on your bad points. Do not hand it to them.</p>
<p><strong>41. If you were hiring a person for this job, what would you look for?</strong><br />
Be careful to mention traits that are needed and that you have.</p>
<p><strong>42. Do you think you are overqualified for this position?</strong><br />
Regardless of your qualifications, state that you are very well qualified for the position.</p>
<p><strong>43. How do you propose to compensate for your lack of experience?</strong><br />
First, if you have experience that the interviewer does not know about, bring that up: Then, point out (if true) that you are a hard working quick learner.</p>
<p><strong>44. What qualities do you look for in a boss?</strong><br />
Be generic and positive. Safe qualities are knowledgeable, a sense of humor, fair, loyal to subordinates and holder of high standards. All bosses think they have these traits.</p>
<p><strong>45. Tell me about a time when you helped resolve a dispute between others.</strong><br />
Pick a specific incident. Concentrate on your problem solving technique and not the dispute you settled.</p>
<p><strong>46. What position do you prefer on a team working on a project?</strong><br />
Be honest. If you are comfortable in different roles, point that out. Always try to go on a higher position.</p>
<p><strong>47. Describe your work ethic.</strong><br />
Emphasize benefits to the organization. Things like, determination to get the job done and work hard but enjoy your work are good.</p>
<p><strong>48. What has been your biggest professional disappointment?</strong><br />
Be sure that you refer to something that was beyond your control. Show acceptance and no negative feelings.</p>
<p><strong>49. Tell me about the most fun you have had on the job.</strong><br />
Talk about having fun by accomplishing something for the organization.</p>
<p><strong>50. Do you have any questions for me?</strong><br />
Always have some questions prepared. Questions prepared where you will be an asset to the organization are good. How soon will I be able to be productive? and What type of projects will I be able to assist on? are examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/50-common-interview-questions-answers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Interview Questions</title>
		<link>http://www.yoursearchbuddy.com/php-interview-questions</link>
		<comments>http://www.yoursearchbuddy.com/php-interview-questions#comments</comments>
		<pubDate>Mon, 13 Dec 2010 23:19:54 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=2054</guid>
		<description><![CDATA[1. What does a special set of tags < ?= and ?> do in PHP? &#8211; The output is displayed directly to the browser. 2. What’s the difference between include... <a class="meta-more" href="http://www.yoursearchbuddy.com/php-interview-questions">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>  <strong> 1. What does a special set of tags < ?= and ?> do in PHP? &#8211; </strong> The output is displayed directly to the browser.</p>
<p>  <strong> 2. What’s the difference between include and require? &#8211; </strong> It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.</p>
<p><strong>   3. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem? &#8211; </strong>PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.</p>
<p><strong>   4. Would I use print &#8220;$a dollars&#8221; or &#8220;{$a} dollars&#8221; to print out the amount of dollars in this example? &#8211; </strong>In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like &#8220;{$a},000,000 mln dollars&#8221;, then you definitely need to use the braces.</p>
<p> <strong>  5. How do you define a constant? &#8211; </strong> Via define() directive, like define (&#8220;MYCONSTANT&#8221;, 100);</p>
<p>  <strong> 6. How do you pass a variable by value? -</strong> Just like in C++, put an ampersand in front of it, like $a = &#038;$b</p>
<p><strong>   7. Will comparison of string &#8220;10&#8243; and integer 11 work in PHP? &#8211; </strong> Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.</p>
<p> <strong>  8. When are you supposed to use endif to end the conditional statement? &#8211; </strong> When the original if was followed by : and then the code block without braces.</p>
<p><strong>   9. Explain the ternary conditional operator in PHP? &#8211; </strong>  Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.</p>
<p> <strong> 10. How do I find out the number of parameters passed into function? &#8211; </strong> func_num_args() function returns the number of parameters passed in.</p>
<p><strong>  11. If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? &#8211; </strong>100, it’s a reference to existing variable.</p>
<p><strong>  12. What’s the difference between accessing a class method via -> and via ::? &#8211; </strong> :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.</p>
<p><strong>  13. Are objects passed by value or by reference? -</strong> Everything is passed by value.</p>
<p><strong>  14. How do you call a constructor for a parent class? &#8211; </strong>parent::constructor($value)</p>
<p><strong>  15. What’s the special meaning of __sleep and __wakeup? -</strong>  __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.</p>
<p><strong>  16. Why doesn’t the following code print the newline properly? </strong>   < ?php<br />
                  $str = ‘Hello, there.nHow are you?nThanks for visiting TechInterviews’;<br />
                  print $str;<br />
          ?></p>
<p>      Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters &#8211; and n.</p>
<p><strong>  17. Would you initialize your strings with single quotes or double quotes? &#8211; </strong>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.</p>
<p><strong>  18. How come the code < ?php print "Contents: $arr[1]"; ?> works, but < ?php print "Contents: $arr[1][2]"; ?> doesn’t for two-dimensional array of mine? &#8211; </strong>Any time you have an array with more than one dimension, complex parsing syntax is required. print &#8220;Contents: {$arr[1][2]}&#8221; would’ve worked.</p>
<p><strong>  19. What is the difference between characters �23 and x23? &#8211; </strong>The first one is octal 23, the second is hex 23.</p>
<p><strong>  20. With a heredoc syntax, do I get variable substitution inside the heredoc contents? &#8211; </strong>Yes.</p>
<p><strong>  21. I want to combine two variables together:</strong></p>
<p>       $var1 = &#8216;Welcome to &#8216;;<br />
       $var2 = &#8216;TechInterviews.com&#8217;;</p>
<p>      What will work faster? Code sample 1:</p>
<p>      $var 3 = $var1.$var2;</p>
<p>      Or code sample 2:</p>
<p>      $var3 = &#8220;$var1$var2&#8243;;</p>
<p>      Both examples would provide the same result &#8211; $var3 equal to &#8220;Welcome to TechInterviews.com&#8221;. However, Code Sample 1 will work significantly faster. Try it out with large sets of data (or via concatenating small sets a million times or so), and you will see that concatenation works significantly faster than variable substitution.</p>
<p><strong>  22. For printing out strings, there are echo, print and printf. Explain the differences. &#8211; </strong>echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like:</p>
<p>       < ?php echo 'Welcome ', 'to', ' ', 'TechInterviews!'; ?></p>
<p>      and it will output the string &#8220;Welcome to TechInterviews!&#8221; print does not take multiple parameters. It is also generally argued that echo is faster, but usually the speed advantage is negligible, and might not be there for future versions of PHP. printf  is a function, not a construct, and allows such advantages as formatted output, but it’s the slowest way to print out data out of echo, print and printf.</p>
<p><strong>  23. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP? &#8211; </strong>On large strings that need to be formatted according to some length specifications, use wordwrap() or chunk_split().</p>
<p><strong>  24. What’s the output of the ucwords function in this example?</strong></p>
<p>      	$formatted = ucwords(&#8220;TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS&#8221;);<br />
      	print $formatted;</p>
<p>      What will be printed is TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS.<br />
      ucwords() makes every first letter of every word capital, but it does not lower-case anything else. To avoid this, and get a properly formatted string, it’s worth using strtolower() first.</p>
<p><strong>  25. What’s the difference between htmlentities() and htmlspecialchars()? -</strong> htmlspecialchars only takes care of < , >, single quote ‘, double quote &#8221; and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.</p>
<p><strong>  26. What’s the difference between md5(), crc32() and sha1() crypto on PHP? &#8211; </strong>The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.</p>
<p><strong>  27. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()? &#8211; </strong>Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.</p>
<p><strong>  28. How do you match the character ^ at the beginning of the string? -</strong> ^^</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/php-interview-questions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug Life Cycle</title>
		<link>http://www.yoursearchbuddy.com/bug-life-cycle</link>
		<comments>http://www.yoursearchbuddy.com/bug-life-cycle#comments</comments>
		<pubDate>Fri, 12 Nov 2010 20:53:10 +0000</pubDate>
		<dc:creator>malvika</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Software QA testing]]></category>
		<category><![CDATA[Software Testing]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=1888</guid>
		<description><![CDATA[Bug Bug is defined as an abnormal behavior of a software. In terms of Testing, bug occurs when there is mismatch in the expected and the actual result.Whenever a tester/... <a class="meta-more" href="http://www.yoursearchbuddy.com/bug-life-cycle">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Bug</strong></p>
<p>Bug is defined as an abnormal behavior of a software. In terms of Testing, bug occurs when there is mismatch in the expected and the actual result.Whenever a tester/ QA  finds a bug in the product, he logs that bug in the bug tracking tool and assigns it to the developer who is responsible.</p>
<p><strong>Bug Life Cycle</strong></p>
<p>Bug life cycle can be defined as in the time period of bug from its birth till it expires.In the life of the bug, it passes on through various stages . These stages are termed as the different statuses of bug.</p>
<p>Various Status of Bugs are:</p>
<p>1. New<br />
2. Open<br />
3. Assign<br />
4. Deferred<br />
5. Reopened<br />
6. Duplicate<br />
7. Rejected<br />
8. Closed<br />
9. Resolved</p>
<p><strong>New</strong>-When a bug is posted by the QA for first time.</p>
<p><strong>Open</strong>- After Posting the bug by QA, the bug is verified by Test lead.After verifying, status of bug is changed to open.</p>
<p><strong>Assigned</strong>-When the Test Lead opens the bug, after that he assigns the bug to the respective developer and now the status of bug changes to Assigned.</p>
<p><strong>Rejected</strong>-If the bug is declared as invalid by developer, the status changes to Rejected.</p>
<p><strong>Resolved</strong>-If the developer finds that the bug is valid and then fixes that bug, then in that case the status of bug changes to Resolved.</p>
<p><strong>Closed</strong>-After the bug has been fixed by developer, the tester\QA verifies the bug and finds that the bug has been resolved. In this case the status of bug changes to closed.</p>
<p><strong>Deferred</strong>-If the status of bug is marked as Deferred, then that bug will be fixed in next release.</p>
<p><strong>Duplicate</strong>-If the bug is repeated twice or the two bugs mention the same concept of the bug, then status of one bug status is changed to Duplicate.</p>
<p><img src="http://www.buzzle.com/img/articleImages/51126-52med.jpg" alt="Bug Life Cycle" title="Bug Life Cycle " /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/bug-life-cycle/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Traceability Matrix</title>
		<link>http://www.yoursearchbuddy.com/traceability-matrix</link>
		<comments>http://www.yoursearchbuddy.com/traceability-matrix#comments</comments>
		<pubDate>Tue, 02 Nov 2010 08:51:56 +0000</pubDate>
		<dc:creator>malvika</dc:creator>
				<category><![CDATA[Interview]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Software QA testing]]></category>
		<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[Traceability Matrix]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=1799</guid>
		<description><![CDATA[Traceability Matrix is used to check the test coverage. In this Matrix, Test cases are mapped with Business Requirement. Basically, the main reason of making a traceability matrix is that... <a class="meta-more" href="http://www.yoursearchbuddy.com/traceability-matrix">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Traceability Matrix is used to check the test coverage.</p>
<p>In this Matrix, Test cases are mapped with Business Requirement. Basically, the main reason of making a traceability matrix is that whether the software which has been designed meets the business/Client requirements.</p>
<p><strong>There are two types of Traceability Matrix</strong>:</p>
<p>1. Forward Traceability Matrix</p>
<p>2. Backward Traceability Matrix</p>
<p>Forward Traceability Matrix says that Requirements are mapped to test cases While Backward Traceability Matrix says that Test cases are mapped to Requirements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/traceability-matrix/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Methodlology Vs Test Strategy Vs Test Approach</title>
		<link>http://www.yoursearchbuddy.com/test-methodlology-test-strategy-test-approach</link>
		<comments>http://www.yoursearchbuddy.com/test-methodlology-test-strategy-test-approach#comments</comments>
		<pubDate>Tue, 26 Oct 2010 12:19:22 +0000</pubDate>
		<dc:creator>malvika</dc:creator>
				<category><![CDATA[Interview]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=1781</guid>
		<description><![CDATA[Usually people get confused between all these terms but there is difference between all these terms. Test Strategy &#8211; It is basically a component of Test Plan Document which illustrates... <a class="meta-more" href="http://www.yoursearchbuddy.com/test-methodlology-test-strategy-test-approach">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Usually people get confused between all these terms but there is difference between all these terms.</p>
<p><strong>Test Strategy</strong> &#8211; It is basically a component of Test Plan Document which illustrates that what types of testing will be done in a particular project and what will be the order of the types of testing done on it.The Test Strategy is decided by the Test Lead.</p>
<p><strong>Test Approach</strong> &#8211; This is basically the perspective of different QA&#8217;s / testers that how will they test the particular module. What approach they will adopt to test the application?<br />
<strong><br />
Test Methodology</strong> &#8211; There are different types of test methodologies followed like Black box, White box and Grey Box.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/test-methodlology-test-strategy-test-approach/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

