TECHY360
Everything You Need To Know About Tech

22 most common questions at the interviews for the position of web developer

0 13

Quality training is one of the key elements necessary for successful interviewing, which, by the way, is often neglected.

Despite the fact that this article does not pretend to objectivity, it includes all the basic questions that can be asked on the topic PHP, JS, JQuery, CSS, HTML, MySQL and OOP, as well as detailed answers to them.

Having studied these topics, you will noticeably improve your theoretical base and significantly increase your chances of getting treasured work.


– How many data types are in PHP?

PHP supports 8 basic data types.

4 scalar types:

– boolean. The logical data type, variables of this type can be true or false.

– integer. Integer data type, variables can take integer values ​​(… -2, -1, 0, 1, 2 …) in the range from -2 ^ 31 to + 2 ^ 31. If the value exceeds this threshold, it is automatically converted to the float type.

– float. The numeric data type is floating point; it can contain both integer and fractional values.

– string. String data type. Contains non-fixed number of different characters. PHP does not impose any restrictions on the length of the line, so you can safely work even with VERY large lines.

2 complex (composite) types:

– array. Array, contains an ordered list of elements.

– object. An object contains an object (an instance of a class).

2 special types:

– resource. Link to an abstract element, so-called. external resource. Examples of external resources – a link to the file and a link to the result of the query.

– NULL. Empty data type indicating the absence of any value. About such values ​​usually say “not defined.” An empty value can initialize variables of any other type.


– What is a static function and how does it differ from the “normal” (non-static)?

Static belongs to a class, not an instance of a class. It is called on the class, not on the object, i.e. directly. Declaring class properties and methods static allows them to be accessed without creating an instance of the class. A class attribute declared static cannot be accessed by an instance of the class (but a static method can be called). Since static methods are invoked without creating an instance of the class, the pseudo-variable is $thisnot available inside the method declared static. Access to static class properties cannot be obtained through an operator ->.


– Is there a difference between single and double quotes in PHP?

In double quotes, the data is “parted”, but not in single quotes. With double quotes in this case will be displayed Chimay, and with single quotes  –  $beer.

$beer = 'Chimay';
echo "$beer";

– Write a program that displays prime numbers, i.e. dividing without balance only on themselves and on 1.

$lst = array();
$k = "prime";

for ($i = 2; $i < 100; $i++) {
    for ($j = 2; $j < $i; $j++) {
        if (($i % $j) == 0) {
            $k = "not prime";
    }
}

if ($k == "prime") $lst[] = $i;
else $k = "prime";
}

foreach($lst as $list) echo $list . "";

– Write a censor program that would replace the user-entered words “fuck”, “idiot” and “bitch” with “f ** k”, “id ** t” and “bi ** h”.

$find = array(
    ‘fuck’,
    ‘idiot’,
    ‘bitch’
);
$replace = array(
   ‘f * *k’,
   ‘id * *t’,
   ‘bi * *h’
);
If (isset($_POST[‘user_input’]) &amp;&amp; !empty($_POST[‘user_input’])) {
    $user_input = $_POST[‘user_input’];
    $user_input_new = str_ireplace($find, $replace, $user_input);
    echo $user_input_new;
}

– What are dynamic variables?

A dynamic variable is one whose name is stored in the variable itself. This is the so-called “variable”. For example:

$var = "first";
$$var = "Second";
// $$var == $first == "Second"

$$var– dynamic, its name may change with the change $var. You can also associate the variable name with the contents of another variable implicitly:

$ first = "second";
$ second = "third";
print $ first; // prints "second"
print $$ first; // prints "third"

– What are design patterns (patterns)?

A design pattern is a common, typical solution to a problem that is repeated many times during the design process of a software product architecture. They show the relationships and interactions between the classes, make the system flexible and easily changeable. Due to their proper use increases the utilization of ready-made solutions.


– Write an example of the implementation of polymorphism.

Class One
{
    function foo()
    {
        echo “Hellofromclass One!”;
    }

    function callMe()
    {
        $this->foo();
    }
}

Class Two extends One
{
    function foo()
    {
         echo “Hellofromclass Two”;

    }
}

$Two = new two();
$Two->callMe();

 – What else are the paradigms (models, approaches) of programming other than OOP?

Of those that are most common: functional, aspect-oriented and procedural.


– It is necessary to output some message by an alert, 3 seconds after the launch of the script. How to do it?

So:

setTimeout(alert(“Hello”), 3000);

Or so:

setTimeout(function() {alert(“Hello”)}, 3000);

– Tell a bunch of words about objects in javascript

Objects (they are associative arrays, hashes) and working with them in JavaScript are not implemented in the same way as in most languages. An object in JavaScript is a regular associative array or, in other words, a “hash”. It stores any “key => value” matches and has several standard methods.


– There are two functions. Is there any difference between them? If so, which one?

function f(a,b) { return a+b }

and

var f = function(a,b) { return a+b }

There is a difference – it is the visibility of the function The variant of the function without varvisible everywhere in the current scope. Including up to the definition of the function. The variant with varassigns a function to a variable, therefore such a function is visible only after the definition.


– What the code does: break me_baby; ?

Exit from the current block of the cycle or switch to the “me_baby” label.


– What is SQL injection?

SQL injection – embedding malicious code in database queries. Using SQL injection, an attacker can not only get sensitive information from the database, but also, under certain conditions, make changes there. Vulnerability to SQL injections arises from the fact that user information gets into a query to the database without proper processing: in order for the script not to be vulnerable, it is necessary to make sure that all user data gets into all queries to the database in a screened form.


– Suppose you have an online store. Make a request that shows how much money each individual buyer has brought in a total of all the time the store has existed.

SELECT customer_name, SUM(order_price)
FROM orders
GROUP BY customer_name;

– What is the difference between writing #my and .my?

#my – ID selector.

.my – class selector.


– What are pseudo-classes?

Pseudo-classes are what they usually write after the selector with a colon to determine the reaction or state for a given selector. The most famous pseudo-classes are: link,: hover,: visited and: active. Pseudo-classes have the following structure:

selector:pseudo class {
    property: value;
}

those. you just need to put a colon between the selector and the pseudo-class.

a.snowman:link {
    color: blue;
}
a.snowman:visited {
    color: purple;
}
a.snowman:active {
    color: red;
}
a.snowman:hover {
    text-decoration: none;
    color: blue;
    background-color: yellow;
}

– Find all the div elements with class one, as well as all p elements with class two, then add them all to class three and visually smoothly down.

$(“div.one”).add(“p.two”).addClass(“three”).slideDown(“slow”);


– Select divs that have no cls class

$(‘div:not(.cls)’);


 – What is the DOCTYPE and why is it needed?

DOCTYPE is the definition of the document type (Document Type Definition (DTD)), the rules according to which the specific document (web page) is checked or (X) HTML. Through this entry, the browser determines which DTD version is used in this document. And it is needed for browsers to correctly display the markup of the document. If DOCTYPE is not specified, then the browser will add a “gag”, and each browser will add its “gag”. As a result, there can be no talk of cross-browser compatibility.


– What are entities?

Entities are combinations of the & character and an alphabetic or numeric code after it intended to replace characters that cannot be found in “pure” form in HTML text, for example, the “<” symbol.


– What are the magical methods you know? What is it all about?

These are methods reserved in php that start with a double underscore “__”.

List of all magic methods:

  • __construct
  • __destruct
  • __call
  • __callStatic
  • __get
  • __set
  • __isset
  • __unset
  • __sleep
  • __wakeup
  • __toString
  • __set_state
  • __clone

__construct and __destruct are the most popular methods that implement the basic concepts of object-oriented programming: constructor and destructor;

__call, __callStatic, __get and __set are methods associated with overloading calls to both properties 
and methods. The __get () and __set () methods are called when setting and getting the property value, 
and the __call () and __callStatic methods are called when the method is called. It is worth noting that these magic functions 
will be called only and exclusively if the requested method or property 
does not exist;

__isset – the method that is triggered when calling functions empty () or isset () on a non-existent 
or inaccessible class property;

__unset – triggered when the unset () function is called on a non-existent or inaccessible class property;

__sleep and __wakeup are methods that are called only from the serialize and unserialize functions, respectively 
. The __sleep method will be called immediately when the serialize function is applied to the object, and 
the __wakeup method is called when unserialize is applied. Currently, methods are used to save the current state of the system and then restore this state 
(for example, a connection to the database);

__toString – a method with which you can refer to a class as a string (for example, 
using print or echo);

__set_state – a method that is called for classes exporting property values ​​by the 
var_export () function ;

__clone – called when cloning an object (entered for use due to the fact that 
objects in php5 and higher are passed by reference);

__invoke – called when trying to use an object as a function.

Get real time updates directly on you device, subscribe now.

Comments
Loading...

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More