Difference between revisions of "Interview Questions"

From Hawk Wiki
Jump to: navigation, search
(Single or Double Quotes?)
(Java)
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Some Translation==
 
==Some Translation==
n! Multiplicative
+
n! Factorial
 +
 
 
==Object-oriented programming==
 
==Object-oriented programming==
 
Check here [[Interview_Questions(OOP)]]
 
Check here [[Interview_Questions(OOP)]]
==C/C++==
+
==C++ Interview==
===ArrayList Vs LinkedList===
+
[[C++ interview]]
ArrayList: fast random access<br>
+
==Javascript/Jquery==
slow at delete<br>
+
[[AJAX&Jquery]]<br>
memory fill up issue<br>
+
[http://{{SERVERNAME}}/downloads/designpattern/ Design Pattern]
LinkedList: slow random access<br>
+
quick delete<br>
+
no memory fill up issue<br>
+
complex data structure<br>
+
  
==PHP==
+
==Algorithm Interview Problems==
===abstract class===
+
[[Algorithm Problems]]<br>
Can not be Instantiable.(cannot become instant. Can only be inherited)<br>
+
==Data Structure==
<pre>
+
[[All about Binary search tree]]<br>
abstract class Fruit {
+
[[All about Linked List]]<br>
private $color;
+
[[Heap & Heap Sort]]<br>
 +
[[TRIE]]<br>
 +
[[Algorithm Sorting]]<br>
  
abstract public function eat()
+
==Regular Expression ==
 +
http://www.zytrax.com/tech/web/regex.htm
  
public function setColor($c) {
+
==PHP==
  $this->color = $c;
+
[[PHP interview]]
}
+
==Java==
}
+
[[Java interview]]
</pre>
+
==Python==
===Single or Double Quotes?===
+
[[Python interview]]
<pre>
+
//Sometimes people use double quotes in PHP to avoid having to use the period to separate code. For example, you could write:
+
$color='red';
+
echo "I have a $color shirt on today<br/>";
+
//Faster however is not always better. A better way to write this code would be:
+
echo 'I have a ' .$color. ' shirt on today<br/>';
+
echo 'I have a $color shirt on today<br/>';
+
</pre>
+
Output:
+
<pre>
+
I have a red shirt on today
+
I have a red shirt on today
+
I have a $color shirt on today
+
</pre>
+
===Avoid Mysql Injection===
+
<pre>
+
$_POST['username'] = 'aidan';
+
$_POST['password'] = "' OR ''='";
+
$query = "SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'";
+
$passwd=mysql_real_escape_string($_POST['password']);
+
$passwd1=addslashes($_POST['password']);
+
echo $passwd."<br />";
+
echo $passwd1."<br />";
+
echo ($query);
+
</pre>
+
Output
+
<pre>
+
\' OR \'\'=\'
+
\' OR \'\'=\'
+
SELECT * FROM users WHERE user='aidan' AND password='' OR ''=''
+
</pre>
+
This would allow anyone to log in without a valid password.
+
 
+
==JavaScript==
+
Closure.
+
<pre>
+
<script>
+
function say667() {
+
  // Local variable that ends up within closure
+
  var num = 666;
+
 
+
  //var sayAlert = function() { alert(num); }
+
  return function() { num++; alert(num); };
+
}
+
 
+
var sayNumba = say667();
+
sayNumba();
+
sayNumba();
+
</script>
+
</pre>
+
The example will keep var num in the memory. alert 667 and 668 on each call;
+

Latest revision as of 00:27, 17 March 2015

Some Translation

n! Factorial

Object-oriented programming

Check here Interview_Questions(OOP)

C++ Interview

C++ interview

Javascript/Jquery

AJAX&Jquery
Design Pattern

Algorithm Interview Problems

Algorithm Problems

Data Structure

All about Binary search tree
All about Linked List
Heap & Heap Sort
TRIE
Algorithm Sorting

Regular Expression

http://www.zytrax.com/tech/web/regex.htm

PHP

PHP interview

Java

Java interview

Python

Python interview