DEV Community

Diaa Elkhateeb
Diaa Elkhateeb

Posted on

Simple technical questions

Simple technical questions that show how deep you are understanding the code you write.

I always believe in nontraditional ways of finding talented people to join my team.ِ Also, I follow some tricks of mine when I involve in an interview to pick the team I am going to join.

One way of interviewing candidates is to ask simple technical questions that have philosophic answers. Even, if the candidate answers the question correctly, I ask him why this natively got existed. This way I make sure that developer understands well the code he choose to write. I always believe that everything on this universe has a philosophy and a rule of bring it to the reality.

A C# example of such questions is:

What is the difference between each line of code below in terms of performance and execution time?

        var i = 7;
        int j = 8;
        var x = new int[] { 9 };
        object y = new int[] { 10 };
        int[] z = new int[] { 11 };

        Console.WriteLine("i " + i);
        Console.WriteLine("j " + j);
        Console.WriteLine("x " + x[0]);
        Console.WriteLine((y as int[])[0]);
        Console.WriteLine(z[0]);
Enter fullscreen mode Exit fullscreen mode

The candidate needs to explain the differences here, which one is better and how compiler executes them. Hypothetically, all of them should give the same result, but which one developer would use in his code. Here, he should understand var, object and explicit typed array declaration.

Another example is to give him an array of 10 elements with one element repeated. The job is to find the repeated element with only one loop. For instance,

var arr = new int[] {1, 4, 8, 30, 4, 77, 5, 0, 10, 9}
Enter fullscreen mode Exit fullscreen mode

He needs to find (4) with only one loop.

Such simple questions does not measure his competence regarding C# as a programming language as I am not convinced to stick to specific language. They measure his talent, how he thinks and how well he plays with the programming language.

Top comments (2)

Collapse
 
sanderintveld profile image
Sander in 't Veld

Wait, does "only one loop" here mean only one for-loop, or only visiting each element once? Because I'm pretty sure the latter is impossible... right?

Collapse
 
diaakhateeb profile image
Diaa Elkhateeb

one for-loop.