Tuesday 6 August 2013

Sirion Labs Interview

Sirion Labs
Interview:
Venue: Palm something, Gurgaon. Within 15 minutes ride from Sikandarpur metro station. Auto wala will charge around 50 bucks to land you straight up there.
Date : 3 August 2013
                    
Round I:
First round is Java basics. Well, not that basic. The questions keep getting twisty as you move through the paper. Some of them are plain silly. And yes, there are a couple of questions relating to data structures as well.
In total there are 16 questions.
No marking at all. They will simply discuss the solution to the answers. So be cautious about any guess that you make. In the interview they will discuss any question that you marked as wrong or any such question that turned out to be right in your case, but the majority got it wrong.
Questions of first round (in no particular order):

1.             class A
{
    public static void  X()
  {
          Y();
  }
  public static void Y()
  {
        System.out.println("parent");
  }
}

public class B extends A
{
        public void Y()
        {
                System.out.println("Child");
        }
}
What will the following code snippet print?
B.X() ?
Ans.
Explanation: From the first look it appears that either Parent or Child will be printed. But, there’s a catch. All the methods are static and static methods cannot be overridden as they are properties of class.

2.    try
{
   int a = 5;
   System.out.println("Try");
}
catch(Exception e)
{
    System.out.println("Exception is ="+a);
}
What will be printed on running the above code snippet?
Options:
A)     Try
B)      Exception
C)      Run time error
D)      Compile time error
Ans. D) Compile time error
Explanation: You may spend a lifetime trying to figure out what’s wrong with the above code and still write A with an uneasy feeling that something is definitely amiss, maybe I am just overlooking it. Your gut feeling is correct. Something is amiss. But it’s just silly. Did you notice that the variable ‘a’ is being called in exception block while its scope ends in ‘try’? See, it’s silly. The code will simply give a compile time error.

3.   A very long question. First it lists the definition of in order, pre order and post order traversal. It refers to post order as reverse order. Whoever came up with that? Then it innocently gives the pre order traversal of a tree. ABCDE. As expected, the question asks to come up with the corresponding in order and post order traversal.
Options:
A)     CBDAE, CDBAE
B)     Insufficient data, CDBAE
C)     Insufficient data, CABDE
D)     Insufficient data, insufficient data
Ans.
Explanation: This question can have two possible answers.
In option A if we consider the in order traversal ‘CBDAE’ as part of the question then CDBAE is indeed the correct post order traversal. Hence, A is correct.
Both, B and C are incorrect because we cannot find the post order traversal without knowing both the in order and pre order traversal.
D can also be correct as only pre order traversal cannot give us both the post order and in order traversal.

4.         String a = null;
    String b = "xyz";
    String c = a+b;
    System.out.println("c");
   
What will be the output on running the above code snippet?
Options:
A)     xyz
B)     nullxyz
C)     Complie time error
D)     Run time error

5.   public int method(int n)
    {
        int result = 0;
        n <<= 1;
        while (n > 0) {
            result += (n / 2) % 2;
        }
        return result;
    }
The method is called as method(13977) or some very large odd number. What will the method return in the variable result?
Ans.
Explanation: N<<=1 simply multiplies N with 2. It is equivalent of n*=2.

6.   The entire code for reversing a link list. They just removed the initialization part and the part inside the loop. You have to write that part.

7.  int result =0;
   for (int i =0; i< 10; i++)
   {
       for (int j=0; j<10; j++)
       {
              result+=i+j;
       }
     }
     What will be the value of result?
Ans.
Explanation: The catch in this question is that i+j will be calculated after result+=i is calculated so result will eventually be ∑(10*i) i.e. (10*0+10*1+10*2…….+10*9).

      There were 9 other questions. Most of them, related to inheritance.

Round II
All the questions were related to algorithms. You can choose any language you wish.

1.   There is a 2-D matrix of 0’s and 1’s.  Given a 2D array of 1's and 0's, find the size of the largest block of 0's. For example the following 2D array:
int[][] array = {
                     {1, 0, 1, 0, 0, 0, 1, 0 },
                     {1, 0, 0, 0, 0, 0, 1, 1 },
                     {1, 1, 1, 0, 0, 0, 1, 1 }
                     };
Will return "9", because there is a 3x3 square of 0's, and that is the biggest block of 0's in the 2D space.

2.   Find the largest distance between two nodes in a binary tree.
The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree. The diagram below shows two trees each with diameter nine, the leaves that form the ends of a longest path are shaded (note that there is more than one path in each tree of length nine, but no path longer than nine nodes).
The diameter of a tree T is the largest of the following quantities:
* the diameter of T’s left sub tree
* the diameter of T’s right sub tree
* the longest path between leaves that goes through the root of T (this can be computed from the heights of the sub trees of T)

Interview:
1.   Implicit objects in JSP?
2.   What happens if destroy() is called on a servlet object?



       

5 comments:

  1. That was all about the interview.......!!! What after that???? Did you clear the written round??? And what about the HR round???
    And pls suggest your overall overview about the company as well...... :-)

    ReplyDelete
    Replies
    1. Hi Neeraj,
      I did clear the written round and was called for and went for an interview. It was pretty strange by my standards as the interviewer frequently checked out of the room for smoking (...fix). Baring that he himself was not confident on many Java concepts. Discussed puzzles for a long long time, got a little obsessed about them as well. Still i was under the impression that i was selected as i answered most of the questions. But i did not get a call. :(

      Delete
    2. This comment has been removed by the author.

      Delete
  2. @Qualter Demix :

    I think for question 3, if 'A' is an answer then it should be CBDAE, CDBEA. Post order should be CDBEA.
    Other wise only the 'D' is correct.

    ReplyDelete
  3. It should be System.out.println(c); instead of System.out.println("c");

    ReplyDelete