Code Pumpkin

Sapient Global Markets Interview Questions – Set 2

September 12, 2017
Posted by Rama Prasad

I applied for Junior Associate position (Java Developer) at Sapient Bangalore location. This was my second technical round with Sapient Global Markets, Bangalore. It was Skype interview.  You can also read my article for the interview experience of first technical round at Sapient

From my interview experience with Sapient, I can say that their interviewers have some listed topics or categories and they need to assess interviewee based on that. Interviewer will give rating based on your knowledge in each category i.e. 1 for Basic Knowledge, 2 for Good Knowledge and so on.

I have tried to group questions asked to me based on those categories:

  1. Collections
  2. Fail-Fast vs Fail-Safe
  3. Multithreading
  4. Garbage Collection
  5. Knowledge on Immutability
  6. Design Patterns
  7. Design Principles
  8. Algorithms and Problem Solving
  9. Java 8 Features
  10. SQL
  11. Web Services 
  12. Spring and Hibernate
  13. General Technology knowledge (NoSQL DB, JMS, JUnit, Build Tools, Version Control Tools)

1. Collections

  1. How does HashMap work? Explain hashCode() and equals() method.  (Answer)
  2. Is equals method used only in put() operation or also used in get() operation?
    Answer : both. see put() and get() operation in HashMap
  3. What is rehashing?
  4. What is the time complexity of put and get operation in HashMap? (Answer)
  5. I have below Employee class. I want to create a ArrayList of Employee objects  and I want to sort that list by firstName. How I can do that? Write java code for the same.

class Employee{
    String firsName;
    String lastName;
    int age;
    int salary;
  1. If I want to maintain insertion order in the map, which collection should I use?
    Answer : LinkedHashMap
  2. How does LinkedHashMap maintain insertion and access order internally?
  3. What is PriorityQueue? Which data structure it uses internally?
  4. Difference between PriorityQueue, LinkedHashSet and TreeSet. When you will prefer one over other.
  5. If I will create ArrayList of above Employee object, how can I sort that?
    Answer : Collection.sort()
  6. Is there any other way by which we can sort Employee objects (other than Collections.sort() )?
    Answer : TreeSet
  7. What will happen if I will not implement Comparable or pass additional Comparator in Collection.sort() method or constructor of TreeMap?
  8. In what condition, TreeMap will throw ClassCastException?
  9. What is the time complexity of Collections.sort() method?
    Answer : O(nlogn)
  10. Can you optimize the time complexity of Collections.sort() ?
  11. Write down code for creating custom Generic class and Method.

2. Fail-Fast vs Fail-Safe

  1. Difference between fail-fast and fail-safe iterator.
  2. List down the JDK Collections which provides fail-fast and fail-safe iterator.
  3. Can fail-fast iterator throw ConcurrentModificationException in single thread environment? If yes, in which situation?

3. Multithreading

  1. What all classes of concurrent API have yoy used? 
  2. Difference between CountDownLatch and CyclicBarrier.  (Answer)
  3. How does ConcurrentHashMap work internally?

4. Garbage Collection

  1. What do you know about Garbage Collection?
  2. How many types of GC are there in Java? Which GC is configured as default one?
  3. Difference between Minor GC, Major GC and Full GC.

5. Knowledge on Immutability

  1. How to create Immutable class?  (Answer)
  2. If I will not declare my Immutable class final, how immutability can be broken?
  3. Suppose My Immutable class is having reference of another mutable class, how I will prevent any modification in that class? Assuming that class is Third Party class and it has not implemented Serializable and Clonable iterface. (Answer

6. Design Patterns

  1. Which all design patterns have you used? (Refer Design Patterns)
  2. Can you write down a code to create Immutable class using builder design pattern. (Answer)

7. Design Principles

  1. Do you know any design principle? – SOLID
  2. Do you know any other design principles than SOLID?
  3. What L and I stands for in SOLID?

8. Algorithms and Problem Solving

  1. Write down a program to dispaly singly linked list in reverse order.

9. Java 8 Features

  1. Do you know any fetures of Java 8? (Refer : Java8 Features)
  2. What is Functional interface in Java 8? (Answer)
  3. Is Serializable Functional interface? – No. Serializable is Marker Interface.
  4. What is Lambda Expression? Write down a sample code for lambda expression. (Answer)
  5. What is parallel stream in Java 8?

10. SQL

  1. What is the difference between clustered and non-clustered index?
  2. Employee table is having Employee_Name and Salary column. Write down a query to get employee with 4th largest salary using oracle's rank() function.

11. Web Services 

  1. Have you ever published your webservice? or are you just consuming webservices?
  2. What is HTTP Status code for success, access forbidden, Page not found and server error?
  3. What is the difference between POST and PUT method?
  4. What all format does SOAP webservice support?

12. Spring and Hibernate

  1. Which all Spring components have you used?
  2. LifeCycle of Spring Bean.

13. General Technology knowledge 

  1. Have you ever used NoSQL?
  2. Have you ever worked on JMS?
  3. What do you use for Unit Testing in your project?
  4. What is mock objects in JUnit?
  5. What all UI technologies have you worked on?
  6. Do you know shell scripting or python? 
  7. What should be the first line in shell script file?
  8. Which building tool are you using? – Ant and Maven
  9. Which version control tool are you using?

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";
For more information on supported HTML tags in disqus comment, click here.
Total Posts : 124
follow us in feedly

Like Us On Facebook