Code Pumpkin

Sapient Global Markets Interview Questions – Set 1

September 9, 2017
Posted by Rama Prasad

I applied for Junior Associate position at Sapient Bangalore location. Recruiter contacted me via LinkedIn. There were two technical rounds (Skype Interviews) and one managerial round. Over all experience was really good and I enjoyed entire interview process.

Here are the questions asked to me in my first technical round.

  1. Write a program to swap a String ​without using temp variable.
  2. Difference between String, StringBuilder and StringBuffer?
  3. How to create custom Immutable Objects in java? (Answer)
  4. If in my immutable class, one of the field is having reference of third party class which is mutable,  how I will ensure immutability of my class? (Answer
  5. If I am having ArrayList as a field in my immutable class, how I will restrict modification in that ArrayList? (Answer
  6. Design a customer care system of an image given below.

Design Description:

  • There are two entry gates (Entry1 and Entry2) and one token counter (T1 and T2) for each gate.
  • Customer needs to collect token from any of the token counter.
  • Unique token should be generated concurrently. For example, if counter T1 generates token number 4 and at the same time, another token is being generated from counter T2, it should be 5. There should not be any inconsistency. 
  • There are two Complaint Counter (C1 and C2) and both of them have their individual display screen (D1 and D2 respectively)
  • Display screen can display at most three numbers at a time. Same token number should not be displayed in both the screen.
  • Customers with remaining tokens need to wait in Waiting area. 
  • Once Complaint will be resolved for any token, Display screen will remove that number and add new token number from waiting queue. 

    Design Interview Question | Sapient Global Markets

    What all things we need to design for above problem?

    • Which design pattern will you use? why? – Producer Consumer Design Pattern
    • Which data structure you will use? – BlockingQueue 
    • What all classes you will create?
    • Draw a class diagram and explain the relation between each class.
    • How you will handle uniqueness of tokens at T1 and T2?

    1. As a follow up question to my class diagram in above question, he asked me the difference between aggregation and composition?
    2. I want to print alphabet from A to Z with S as midpoint using 6 different threads. For example, first you need to print A to S using 6 threads, then print string MIDPOINT and then print characters from T to Z using same 6 threads. How you will do that? Which utility you will use? – Answer is CyclicBarrier
    
    A
    B
    C
    .
    .
    Q
    R
    S
    MIDPOINT
    T
    U
    V
    .
    .
    X
    Y
    Z

    1. Why can't we use CountDownLatch in above example?
    2. What will happen if I have initialized CountDownLatch with count as 3 and If I will call latch.await() method four times?
    3. For below given SQL Table
    EmpId FirstName LastName
    100 Rama Prasad
    101 Amrita Iyer
    102 Kamal Hasan

    Write a query to fetch result as below

    EmpId Full Name EmailId
    100 Rama Prasad rprasad@sapient.com
    101 Amrita Iyer aiyer@sapient.com
    102 Kamal Hasan khasan@sapient.com

    SQL Query

    
    Select 
        EmpId,
        FirstName || ' ' || LastName as "Full Name",
        lower(substr(FirstName,0,1) || LastName || '@sapient.com') as "EmailId"
    From 
        Employee;

    I used || operator, substr and lower function. Interviewer asked me which function you can use if you do not want to use || operator.

    That's it. 🙂  

    Rama Prasad has also share his experience of second technical round with Sapient


    This article is contributed by Rama Prasad. If you would also like to contribute your article or share interview experiences, you can create contributor account with codePumpkin by clicking here.

    That's all for this topic. If you guys have any suggestions or queries, feel free to drop a comment. We would be happy to add that in our post. You can also contribute your articles by creating contributor account here.

    Happy Learning 🙂

    If you like the content on CodePumpkin and if you wish to do something for the community and the planet Earth, you can donate to our campaign for planting more trees at CodePumpkin Cauvery Calling Campaign.

    We may not get time to plant a tree, but we can definitely donate ₹42 per Tree.



    About the Author





    Tags: , , , , , ,


    Comments and Queries

    If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
    <pre><code class="java"> 
    String foo = "bar";
    </code></pre>
    
    For more information on supported HTML tags in disqus comment, click here.
    Total Posts : 124
    follow us in feedly

    Like Us On Facebook