Sapient Global Market Java Interview Questions and Coding Exercise

Carvia Tech | May 18, 2019 at 06:58 PM | 626 views


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 discussed here

  2. Designing Smart Card System for Delhi Metro - Coding Exercise in Java. 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)

Top articles in this category:
  1. Morgan Stanley Java Interview Questions
  2. Citibank Java developer interview questions
  3. UBS Top 10 Java Interview Questions
  4. Top 50 Multi-threading Java Interview Questions for Investment Banking Domain
  5. BlackRock Top Java Interview Questions: Investment Banking Domain
  6. RBS Java Interview Questions
  7. Cracking core java interviews - question bank


Find more on this topic:
Java Interviews image
Java Interviews

Interview - Product Companies, eCommerce Companies, Investment Banking, Healthcare Industry, Service Companies and Startups.

Last updated 1 month ago


Recommended books for interview preparation:
You may also be interested in..
Generic placeholder image
ebook PDF - Cracking Spring Microservices Interviews for Java Developers
You may also be interested in..
Generic placeholder image
ebook PDF - Cracking Java Interviews v3.5 by Munish Chandel

This website uses cookies to ensure you get the best experience on our website. more info