|
| 1 | +Object Oriented Programming (OOP) |
| 2 | +Git 8 |
| 3 | +PHP 5 9 |
| 4 | +CakePHP framework 9 |
| 5 | +MySQL 9 |
| 6 | +Javascript 8 |
| 7 | +jQuery 9 |
| 8 | +HTML 9 |
| 9 | +CSS 8 |
| 10 | +Linux/Unix based OS 8 |
| 11 | + |
| 12 | +Questions: |
| 13 | + |
| 14 | +About OOP: |
| 15 | +How do you declare a function or method that you want to be accessed without instantiate the class? |
| 16 | +- By defining function static |
| 17 | + |
| 18 | +Class AccessSpecifiers { |
| 19 | + |
| 20 | + public static function testStatic() { |
| 21 | + return false; |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +How do you create a child class of BaseClass ? |
| 26 | +- Through inheritence using keyword extends |
| 27 | +Class MyParent {} |
| 28 | + |
| 29 | +Class Son extends MyParent {} |
| 30 | + |
| 31 | +About GIT: |
| 32 | + |
| 33 | +If you accidentally add the wrong files to be commited using git add, how do you unstage them? |
| 34 | +- git rm --cached <file> |
| 35 | + |
| 36 | +If you want to switch to another branch, what command you need to execute? |
| 37 | +- git checkout branchName |
| 38 | + |
| 39 | +About PHP 5: |
| 40 | + |
| 41 | +Please write a conditional block of code that check if the variable $var exists, is not null and it's a number. |
| 42 | +- Solution: |
| 43 | +Class TestVar { |
| 44 | + |
| 45 | + public static $var; |
| 46 | + |
| 47 | + public static function checkVar($var) { |
| 48 | + self::$var = $var; |
| 49 | + if (property_exists(__CLASS__,'var') && |
| 50 | + !is_null(self::$var) && |
| 51 | + is_int(self::$var)) { |
| 52 | + echo self::$var; |
| 53 | + } else { |
| 54 | + echo 'undefined var'; |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | +TestVar::checkVar(10); |
| 59 | + |
| 60 | +Write a function that adds a line to a log file the current date and time with this format: "[2013-09-23 00:30:15] - Status OK" |
| 61 | +- Solution : |
| 62 | +Class LogString { |
| 63 | + |
| 64 | + private $__var; |
| 65 | + |
| 66 | + public function __construct() { |
| 67 | + error_log("[".date("Y-m-d H:i:s")."] - Status OK", 3, "error.log"); |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +$obj = new LogString(); |
| 72 | + |
| 73 | + |
| 74 | +About CakePHP |
| 75 | + |
| 76 | +Which is the default path where you set up the configuration for the database? |
| 77 | +- /project/app/Config/database.php |
| 78 | +How you can get the value of a session variable with key "foo" using CakePHP ? |
| 79 | +- $this->Session->read('foo'); [$this is the reference to Controller child] |
| 80 | + |
| 81 | +About MySQL |
| 82 | + |
| 83 | +Write a single query to retrieve the information from 2 tables that are related( users and users_data) where the primary key on users is ID and the foreign key on users_data is USER_ID. |
| 84 | +- Query: |
| 85 | + SELECT users.*, users_data.* FROM users |
| 86 | + LEFT JOIN users_data |
| 87 | + ON users_data.USER_ID = user.ID; |
| 88 | + |
| 89 | +Write a single query to retrieve all the queries that are currently running on the server . |
| 90 | +- Query |
| 91 | + SHOW PROCESSLIST; |
| 92 | + |
| 93 | +About Javascript |
| 94 | + |
| 95 | +How do access to the alt attribute of the following image element using javascript? |
| 96 | +- Using getElementsByTagName('img')[0].alt; |
| 97 | + Example : |
| 98 | + var testStr = '<img alt="ALT TEXT" src="myPic.jpg">'; |
| 99 | + var tmp = document.createElement('div'); |
| 100 | + tmp.innerHTML = testStr; |
| 101 | + var alt = tmp.getElementsByTagName('img')[0].alt; |
| 102 | + |
| 103 | + |
| 104 | +What is the protocol name behind ajax? |
| 105 | +- JSON |
| 106 | + |
| 107 | +About jQuery |
| 108 | + |
| 109 | +Write a piece of javascript code using jQuery that make the element with id "someElement" to appear on the screen using a fade in effect after the DOM is loaded. |
| 110 | +- Solution : |
| 111 | + $(document).ready(function () { |
| 112 | + $("#someElement"). fadeTo( "slow", 0.12 ); |
| 113 | + }); |
| 114 | + |
| 115 | +How do you remove an element from the DOM using jQuery? |
| 116 | +- .remove([selector]) |
| 117 | + |
| 118 | +About HTML |
| 119 | + |
| 120 | +Which is the doctype syntax for HTML5? |
| 121 | +<!DOCTYPE> |
| 122 | + |
| 123 | +Which is the attribute and value required on forms to allow file uploads? |
| 124 | +- The type="file" attribute of the <input> tag with value "file" |
| 125 | + |
| 126 | +About CSS |
| 127 | + |
| 128 | +Which is the css property and its value to force to hide the scroll on any DOM element with fixed height when its content exceed its own height? |
| 129 | +- overflow=hidden |
| 130 | + |
| 131 | +If you have to div elements next to each other with the property float:left, which CSS property do you need to add to the next element in order to get both of them to fill the same height on page and make the next one not a floating one? |
| 132 | +- Example: |
| 133 | +<style> |
| 134 | +body |
| 135 | +{ |
| 136 | +margin:0; |
| 137 | +padding:0; |
| 138 | +} |
| 139 | +.container |
| 140 | +{ |
| 141 | +position:relative; |
| 142 | +width:100%; |
| 143 | +} |
| 144 | +.right |
| 145 | +{ |
| 146 | +float:left; |
| 147 | +width:150px; |
| 148 | +background-color:#b0e0e6; |
| 149 | +} |
| 150 | +</style> |
| 151 | +<div class="container"> |
| 152 | +<div class="right"> |
| 153 | +<p><b>Note: </b>When aligning using the position property, always include the !DOCTYPE declaration! If missing, it can produce strange results in IE browsers.</p> |
| 154 | +</div> |
| 155 | +<div style="position:relative; width:300px;"> |
| 156 | +<p><b>Note: </b>When aligning using the position property, always include the !DOCTYPE declaration! If missing, it can produce strange results in IE browsers.</p> |
| 157 | +</div> |
| 158 | +</div> |
| 159 | + |
| 160 | +About Linux / Unix based OS |
| 161 | + |
| 162 | +Which protocol(s) you could use to connect to a server SHELL remotely? |
| 163 | +SSH |
| 164 | +Write a command to look for the word "logString" on all files with .ctp extension in the same director |
| 165 | +grep -rw "ads" /home/anit/*.ctp |
0 commit comments