Sapient Global Market Java Interview Questions and Coding Exercise

Upasana | July 05, 2019 | 3 min read | 9,358 views | sapient interviews


Java Interview Questions

  1. How do we synchronize a static method to prevent data corruption in concurrent update?

  2. How will you introduce multi-tasking in your java application?

  3. Design a program to search files inside a directory using multi-threading?

  4. How will you implement a LRU timed cache in Java?

  5. There is a folder containing multiple SQL files. Each file’s name contain a sequence number which determines the execution order of that particular SQL script file. Design an API that will take such folder and execute the SQL in correct order.

  6. What is difference between wait() and sleep() method?

  7. What is a deadlock situation? How will you handle deadlock in development and production environment?

  8. What is mechanism for inter-thread communication?

  9. Would adding multi-threading to sorting algorithm improve its performance?

  10. In what practical scenario’s multi-threading actually improves the performance of Java application?

  11. Do we need to synchronize getter and setter both to prevent concurrency related issues on a collection?

  12. Explain the key classes in java.util.concurrent package?

  13. What is purpose of ConcurrentHashMap?

  14. What is purpose of a Future? How will you use it?

  15. How will you create your own custom threadpool in java without executor framework?

  16. What is a BlockingQueue?

  17. Complete Solution to Delhi Metro Design using Spring MVC with testcases

Coding Exercise

  1. Sapient Fee calculator: Coding problem in Java
    Solution to Sapient Fee Calculator discussed here

  2. Designing Smart Card System for Delhi Metro
    Solution to Delhi Metro Smart Card. implement 'Metro Smart Card System' (MSCS) for Delhi city. For application assume there is a single metro line covering 10 stations linearly. The stations name are A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 as shown below. The travel can be in any direction.

    Travelers have smart cards that behave just like any regular debit card that has an initial balance when purchased. Travelers swipe-in when they enter a metro station and swipe-out when they exit. The card balance is automatically updated at swipe-out.
    Objective of the exercise is to create an automated system that has following functionality:
    2.1 Card should have a minimum balance of Rs 5.5 at swipe-in. At swipe-out, system should calculate the fare based on below strategies set at the start of the day. The fare must be deducted from the card.
    2.2 Card should have the sufficient balance otherwise user should NOT be able to exit.
         Weekday – Rs. 7 * (Number of stations traveled)
         Weekend – Rs. 5.5 * (Number of station traveled if it's Saturday or Sunday)
         (* there can be more such fare strategies in future)
  3. There is three file contains flight data. File data has in csv format. 1)Write a standalone program to search flight detail from all files depend on criteria 2)Criteria would be departure location,arrival location, flight date. 3)Program should follow\Oops principle. And right unit test case also. 4)Result should be in Ascending or descending order. 5)Data separated with pipe | .

    File A has data like below:
    FLIGHT_NUM|DEP_LOC|ARR_LOC|VALID_TILL|FLIGHT_TIME|FLIGHT_DURN|FARE
    AF299|FRA|LHR|20-11-2010|0600|4.10|480
    AF118|DUB|MUC|21-12-2010|1410|5.40|580
    AF371|AMS|MAD|30-11-2010|1210|3.45|320
    File B has data like below:
    FLIGHT_NUM|DEP_LOC|ARR_LOC_VALID_TILL|FLIGHT_TIME|FLIGHT_DURN|FARE
    BA123|DEL|AMS|12-10-2010|0050|8.00|950
    BA412|BOS|CDG|31-12-2010|0210|7.50|800
    BA413|BOS|AMS|30-11-2010|1530|7.00|750
    File C has data like below:
    FLIGHT_NUM|DEP_LOC|ARR_LOC_VALID_TILL|FLIGHT_TIME|FLIGHT_DURN|FARE
    LH348|DEL|AMS|30-11-2010|2325|11.00|1050
    LH201|LHR|MEL|21-11-2010|0230|15.30|1400
    LH342|VIE|JFK|20-10-2010|1130|14.20|980

Coding Exercise Evaluation Criteria

  1. Code Completeness/ Correctness

  2. Code Structure and quality: Modularity, usage of OO principles, size of classes/functions,

  3. Choice of data structures

  4. Unit Test cases

  5. Coding productivity (more time you take to submit the exercise, lesser you will score)

  6. class/function/variable names, package/class structure


Buy my ebook for complete question bank

Most of these questions has been answered in my eBook "Cracking the Core Java Interview" updated on June 2018, that you can buy from this link:

Buy from Shunya (DRM Free PDF download with updates)

sapient interviews:
  1. Sapient Global Markets important topics in Java
  2. Sapient Fee Calculator: Coding problem in Java
  3. Sapient - Coding Exercise for Designing Smart Card System for Delhi Metro
See all articles in sapient interviews
Top articles in this category:
  1. Sapient Global Markets important topics in Java
  2. Multi-threading Java Interview Questions for Investment Bank
  3. Goldman Sachs Java Interview Questions
  4. ION Trading Java Interview Questions
  5. UBS Java Interview Questions
  6. Citibank Java developer interview questions
  7. Java Concurrency Interview Questions

Recommended books for interview preparation:

Find more on this topic:
Buy interview books

Java & Microservices interview refresher for experienced developers.