8 real life Java scenarios with Situation-Action-Result (i.e. SAR) technique

The SAR (Situation-Action-Result) technique is very useful to tackle open-ended questions like:

1. What were some of the challenges you had encountered, and how did you go about fixing them?
2. What are some of your achievements that you are most proud of?
3. Why do you like software engineering?

and the list goes on. The answers you provide will reveal a lot about your experience & industry knowledge & be prepared for further drill-down questions based on your answers & this helps you steer the interview in the right direction leading to enlightening technical discussions.

Firstly, you state the situation that existed in your workplace, then you describe what you did about it and finally you describe the beneficial outcome.

Example 1: Tuning performance

Situation: Performance problem where the application server had to be restarted every second day.


– Used JMeter to simulate the load conditions in a lower environment.

– Identified the cause of the problem to be leaking database connections due to not properly closing the connections under an exceptional scenario.

– Used the profiling tool “VisualVM” & identified a memory leak where long living objects were holding on to short lived objects. jvisualvm to detect memory leak.

– Fixed the database connection leaks by closing the connections in a finally block.

– Fixed the code to release memory consumed by the short lived objects.

– Tuned the JVM & GC settings. 15 key considerations to write low latency applications in Java

– Load and endurance tested the fixed code with the load testing tool JMeter to confirm that the issue has been fixed.

Result: The application became a true mission critical 24×7 type with a much improved performance.

Example 2: Code quality

Situation: Java code that is hard to maintain and reuse. Changes to one module may break another module.


– Wrote unit tests with proper Mockito mock objects for the existing un-maintainable code.

– Introduced SonarQube to ascertain code coverage & code quality metrics. Fixed the blocker, critical, and major severity items.

– Re-factored the code with OO concepts and design patterns in a test driven manner to improve maintainability.

– Large procedural style if/else statements were replaced with objects adhering to the Open-Closed design principle.

– Code duplication was eliminated with the help of SonarQube tool & refactoring.

– Reran the unit tests to ensure that the functionality is not broken due to refactoring.

Result: The application became much easier to maintain, extend, and reuse. The test coverage was increased from 27% to 76%.

Example 3: Quick wins

Situation: The financial service websites are ranked by an independent body, and this particular company’s website that I was the technical lead for was ranked 23rd out of 31 possible companies that took part.


– I took the initiative with the collaboration of the business and technical leaders to launch a “QuickWins” project to improve the overall ranking of the website.

– An independent user experience consultant was hired to analyse and produce a report with 18 most important things that can potentially improve the user friendliness, look and feel, and ease of use of the overall website.

– Out of those 18 recommendations, 4 of them needed major design and development changes, and did not stack up well in the cost-benefit analysis.

– The remaining 14 recommendations were implemented within 3 months.

– The implementation was fast-tracked by adopting some of the agile development practices like iterative development, daily stand-up meetings, test driven development, CI/CD pipelines and regular catch-ups with the business.

Result: This initiative was a major success and the website ranking was improved from being 23rd to 7th. The management was very impressed, and the contributions were well noticed and rewarded. That was also one of my longest and rewarding contracts.

Example 4: Concurrency Management

Situation: The production ready application consumed very less CPU and response times were very poor due to heavy I/O operations like database read/write operations.


– Monitored the CPU usage with Visual VM tool.

– Got a series of thread dumps, say 7 to 10 at a particular interval, say 5 to 8 seconds and analysed those thread dumps by importing the thread dumps into “Samurai”, which is a visual tool.

– Paid attention to the blocked threads in red. Alternatively, VisualVM is handy for debugging deadlocks & analyzing thread dumps.

– Fixed the concurrency issue by reducing the synchronization granularity in the code.

– The offending SQL statement was identified with a SQL query planner and tuned.

Result: The response times were halved and the average CPU usage increased from 45% to 98%.

Example 5: Design

Situation: The business wants to rapidly review & change 200+ rules as the government regulatory & compliance requirements change.


  • Used Drools (i.e. open-source rules engine) to externalise the rules in a Microsoft Excel spreadsheet.
  • The business maintains and versions the Excel spreadsheet with changes to rules & values. Modified rules are uploaded to prep-prod for verification & then finally uploaded to the production.
  • An approval process was designed to enable separate users to authorize the changes before they take effect.

Result: The business was empowered to react rapidly to the regulatory changes from the government. When the regulatory requirements change, the rules within the Excel spreadsheet can be modified in a controlled manner without requiring code changes in most cases.

Drools Tutorials – Non-trivial examples step by step.

Example 6: Security

Situation: The SSL handshake issues whilst deploying the application to production environment.


  • Used keytool to verify certificates in the keystores and trusstores.
  • Enabled SSL debugging and used other handy tools like OpenSSL & SSLPoke, which is a very handy Java program to debug SSL issues.
  • Exported the missing certificates from the browser and imported it into the truststore.

Result: SSL issues were resolved in a timely manner.

Example 7: Technical capabilities & experience

Situation: Develop a stand-alone TCP server that talks to 3000+ petrol pumps as part of the “pay at the pump” solution. The server also needs to integrate with 3+ back-end systems like payment gateway to settle the transactions, loyalty system to accrue & redeem rewards points, data warehouse system to produce 3 dimensional reports, and ESB (i.e. Enterprise Service Bus) to integrate with the ERP system.


  • Developed the stand-alone server using a non blocking I/O framework known as the MINA.
  • As a lead developer, had to liaise with internal staff & external vendors from the USA and South Africa. Attended many conferences and one on one sessions to gather functional & non-functional requirements.
  • Reduced the complexity of the overall system by revising the architecture & reducing the number of messages flowing among various systems from 89 to just 34.
  • Built the system with low latency in mind. 13 Tips to write low latency applications in Java
  • Fixed an intermittent load balancer issue.
  • Managed a team of 7+ developers & liaised with 20+ other stake holders including external vendors, business analysts, systems team & the management.

Result: The high-visibility and low latency application was built on time and within budget with 75% unit test coverage.

Example 8: Facilitating process improvements

Situation: Tasked with transitioning the current project management process from waterfall to agile.


  • Took on the role as a facilitator of the Scrum agile methodology, and empowered the teams to be more self-organizing
  • Promoted Test Driven Development (TDD) and Behavior Driven Development (BDD) practices to increase the automated test coverage from 40% to 70%.
  • Mentored the teams in shifting their mindsets from the big bang approach to iterative & incremental approach with the key focus of delivering a business value in each iteration.
  • Trained staff on writing epics & stories, sprint planning, breaking down the stories into tasks, sizing the stories & tasks, conducting daily scrum & fort-nightly retrospective sessions, velocity points, progress tracking charts like burn-down & burn-up, etc
  • Built CI/CD pipelines with Jenkins & Ansible.

Result: A customized & practical agile process was embraced by the team that worked well for them without all the rigid rules & rituals, but encompassing the core agile values and principles that added value to the business.

Key Take Away

Sell your strengths and well-rounded abilities to add value to the business. Don’t lie by memorising these SAR examples as you will be grilled with further technical questions. This site has examples & tutorials to get hands-on experience with some of these tools. There are YouTube videos and other articles freely available on the internet if you know what keywords to look for. I have covered myriad of Q&As with some key tutorials to quickly get up to speed with the 16+ technical key areas.

The key traits are: 1) passion 2) strong technical skills, 3) necessary soft skills, and 4) right attitude.

So, don’t get annoyed when you are technically grilled or challenged. If you don’t know or in the wrong accept it. Show your enthusiasm to learn. Employers are looking for well rounded professionals, and not just techies.

300+ Java Interview FAQs

Java & Big Data Tutorials