Java Developer Interview Questions
For Java programmers and developers. Interviews focus on object-oriented design, collections, concurrency and memory management.
30 questions, ranked by what the job needs most
Print the top 10:Scoring sheetPractice sheet
Question 1: Walk me through a bug you fixed in Java code that allowed two threads to change shared state incorrectly.
Example answerThe interviewer wants to understand how you diagnose and correct unsafe access to shared state in Java.
Use Situation, Task, Action, Result. Explain the conflicting operations in plain words, your evidence and the protection you added. Show how you checked concurrent behavior afterward.
An example: "Two threads could reserve the last available item because the code checked availability separately from updating it. I reproduced the overlap with a test that coordinated the threads at that point. I changed the code so the check and update happened within the same protected operation, and checked that every access used the same protection. I reran the overlapping case and tested ordinary reservations and failures. The test no longer allowed both requests to reserve the item. I documented the shared-state rule for future changes."
Avoid claiming that delays solve a race, saying a single passing run proves safety, or protecting one code path while leaving other writers unchecked.
Interviewer tipExpect the conflicting operations, evidence of the race, a justified concurrency fix and confirming tests. Adding delays until a test passes does not establish that shared state is safe.
Candidate tipExplain the shared state and the sequence that caused the failure. Focus on how you found the race, corrected access to the state and checked the fix under concurrent execution.
Question 2: Describe a program you wrote to automate a task people had been doing by hand.
Example answerThe interviewer wants to see whether you understood a manual task well enough to automate it and check that the program did the same job correctly.
Explain who did the task, which steps took effort and which part you wrote. Show how you handled an exception that came up in the manual process. End with how you checked the output and what the people using it could do afterward.
"Our office coordinator used to combine supply request sheets by hand. I watched them match item codes across sheets and set aside rows with missing codes for review. I wrote a script that read the sheets, combined requests for the same code and put incomplete rows in a separate file. We compared its totals with a summary the coordinator had already prepared. Once the totals matched, they could start with the combined list and review the flagged rows."
Avoid spending the answer on your choice of language. Don't skip a manual check that the program had to preserve.
Interviewer tipListen for a clear link between the manual task and the code they wrote. A description of the programming language alone leaves it unclear whether the program did the job.
Candidate tipA class project is fine. Explain what the manual task involved, what went into your program, and what it produced for the person doing the work.
Question 3: Give an example of how you changed Java code to reduce excessive memory use in a running application.
Example answerThe interviewer wants evidence that you can use memory observations to make a justified Java code change.
Use Situation, Task, Action, Result. Describe the application symptom, the heap or allocation evidence you gathered, the code you changed and the checks afterward.
An example: "A long-running import service kept using more memory after each completed file. I examined retained objects and found that a static collection still referenced the records from earlier imports. I changed the code so each import owned its temporary records and released references when processing finished. I ran repeated imports with comparable files and watched memory after collection, while also checking imported records and error handling. Memory no longer showed the same growth pattern in those runs. I recorded the workload and the remaining limits of the check."
Avoid guessing from one memory reading, presenting a larger heap as the code fix, or claiming improvement without checking that the application still performs its intended work.
Interviewer tipListen for heap or allocation evidence, the code change and a measured comparison. Raising the heap limit alone without identifying why memory kept growing is a weak answer.
Candidate tipDescribe the memory symptom and the evidence you gathered. Explain what you changed in the Java code and how you checked memory use and application behavior afterward.
Question 4: Walk me through a trial run you used to check whether a program's output matched the specification.
Example answerThe interviewer wants to know how you turn a written specification into an expected result you can check during a trial run.
Choose a trial where you knew what the correct output would look like before running the program. Name the rule you tested and explain how you picked the inputs, calculated the expected output and compared it with the run. Describe what you did with any difference.
"I tested a program that generated a weekly list of open service requests. The specification said a request closed before the reporting cutoff should be excluded. I set up sample requests on both sides of the cutoff and wrote down which ones I expected in the report. The trial included a request closed just before the cutoff. I traced that row to a filter using the wrong date field, corrected it and reran the sample. The report then matched the list I had worked out."
Avoid checking only that the program ran. Don't treat existing output as the expected result without checking it against the specification.
Interviewer tipListen for an expected result worked out before the run and a comparison with what the program produced. A run that finishes without errors can still return the wrong result.
Candidate tipA course lab works here. Pick one trial run, name the input and the result you expected from the specification, and explain how you checked the actual output.
Question 5: Describe a Java program where a class diagram helped you choose between implementing an interface and extending a class.
Example answerThe interviewer wants to see how a diagram shaped a Java inheritance decision in a program you wrote.
Choose one implemented design. Explain the program's purpose and the relationships shown in the class diagram. Describe why implementing an interface or extending a class suited those relationships, then connect the choice to the code and result. Include any design change you made during implementation.
For example: "I wrote a Java program with several exporters. The diagram showed that each exporter needed the same export operation, but they did not all share state or initialization. One exporter already extended a library class. I defined an interface for the export operation rather than require every exporter to extend a common superclass. The diagram helped me separate the shared contract from implementation details, and callers could use the exporters through that interface."
Avoid claiming Java supports multiple class inheritance, naming diagram types without explaining their use or describing a design that never reached working code.
Interviewer tipExpect a link between the diagram, Java's class inheritance limits and the implemented design. Naming interfaces and superclasses without explaining the choice is a weak answer.
Candidate tipUse a program you wrote. Explain the behavior or shared state shown in the diagram, the Java inheritance choice you made and how that choice worked in the code.
Question 6: Describe a time you weighed two ways to store data that a program needed to look up later.
Example answerThe interviewer wants to see how you chose a way to store data based on how the program would retrieve and update it.
Describe the data and give an example of a lookup the program needed to make. Name the two storage options you considered and the trade-off that mattered. Explain what you chose and how you checked that it suited the program's needs.
"In a parts lookup tool, I weighed keeping the catalog in a local file against putting it in a small database. A file would have been simple to ship, and it worked well for looking up a part by number. The support team also needed to search by supplier and update individual entries. I tried those operations with a sample catalog. The database made the searches simpler and let an update touch just one record, so I chose it and used the sample to check the lookup results."
Avoid listing tools without explaining the lookup they support. Don't assume your choice was faster unless you measured it.
Interviewer tipListen for a strength and a drawback of each option given the program's needs. Claiming one way to store data is always faster without considering the kind of lookup is a red flag.
Candidate tipName both approaches and the trade-off that mattered for those lookups, such as search speed or how often the data changed. Say how the comparison shaped your choice and what happened when you used it.
Question 7: Tell me about a time a conversation with a teammate helped you pin down why a program was giving the wrong result.
Example answerThe interviewer wants to know how a teammate's knowledge helped you explain a wrong result from a program.
Set up the discrepancy and mention what you had already checked. Show what you brought to the conversation, what the teammate knew and how you tested the explanation. End with the cause you found and what you did about it.
"A monthly order summary showed more shipments than the warehouse expected. I traced one order through the report and showed a teammate the two rows it produced. My teammate explained that reprinting a label added another label record for the same shipment. I pulled the shipment history for that order and confirmed the extra row came from a reprint. I changed the summary to count shipments by shipment ID and checked it against other orders with reprints."
Avoid saying the teammate fixed it without explaining your part. Don't treat a plausible explanation as confirmed until you've checked an example.
Interviewer tipListen for a clue the teammate supplied about the expected output or the code and how the candidate used it. Forwarding a bug report without discussing the problem gives no evidence of a joint diagnosis.
Candidate tipDescribe the wrong result, what you brought to the conversation, and the clue your teammate added. End with what you were able to pin down or fix because of that input.
Question 8: Walk me through a time you documented a program change so another programmer could pick up where you left off.
Interviewer tipGood handoff notes help a teammate understand why the code changed and how to check it. A list of files with no explanation of the change leaves the next programmer guessing.
Candidate tipChoose a real change and describe what you wrote about why it was made and how to test it. Mention any teammate feedback that showed what was clear or what could use more detail.
Question 9: Tell me about a time you applied a new programming tool, technology or technical information to improve your team's work.
Example answerThe interviewer wants to learn how you applied new technology or information to produce a useful change in programming work.
Use Situation, Task, Action, Result. Describe the team's need, the new tool or information and your role in applying it. Explain the checks you made and the benefit you could actually observe.
An illustrative example: "Our team maintained a reporting program, and I applied a new testing approach when adding an export. I started with a small part of the code, built checks for date handling and compared the generated files with known examples. I asked another developer to review the tests before we used them for later changes. A test caught an end-of-month date error before release. I corrected the export and added the case to our regular checks, so the team could catch the same error when changing that code again."
Avoid listing technologies without an application, claiming a tool was better simply because it was new, or inventing time savings. State any limits in how you measured the benefit.
Interviewer tipListen for a concrete application in code or a programming workflow and evidence of its benefit. Claiming improvement simply because the technology was new is a red flag.
Candidate tipName the new tool or information and the programming problem it addressed. Focus on how you applied it, checked the work and assessed the benefit to your team.
Question 10: Tell me about a time you worked with a teammate who was hard to deal with, such as during code reviews or on a shared program.
Example answerThe interviewer wants to know whether you can work professionally with a difficult teammate while keeping programming work moving.
Use Situation, Task, Action, Result. Describe the behavior and its effect on the code review or shared program. Focus on your own actions, then explain the outcome and anything you would change.
Sample answer: "A teammate rejected my changes in code reviews with short comments that did not explain the problem. I asked for a conversation about a specific review. They were worried that the new code would be hard to test. I added testing notes to my changes, and we agreed that review comments should name the concern and explain the requested change. Our next review focused on test coverage rather than personal criticism. I learned to ask about a concern before assuming what a comment meant."
Avoid attacking the person's character, claiming you were entirely right, or hiding information to undermine them. Involving a lead can be appropriate when a conflict remains unresolved.
Interviewer tipListen for specific steps to resolve the code-review conflict and keep work moving. Personal attacks or hiding information to undermine the teammate are red flags; involving a lead can be appropriate.
Candidate tipDescribe the behavior, not the person's character. Explain what you did to keep the work moving, such as talking one on one or agreeing on review rules, and how the working relationship ended up.
Question 11: Walk me through the programming work you've done on your most recent projects.
Example answerThe interviewer wants to understand what you've programmed recently and which parts of each project you handled yourself.
Choose a recent project you can explain in some depth and a second one that shows a different kind of programming work. For each, say who needed it, what you built or changed, and how you checked it. Spend the most time on a decision or problem you worked through. A recent course project can work if it gives you that detail.
"I recently wrote the import step for an internal inventory tool. I mapped fields from the incoming file to our records and added a separate report for rows the tool couldn't read. I checked the import against a sample the inventory team had already reconciled. On another project, I changed a report export so staff could filter by date, and I tested records on the first and last days of the range."
Avoid rattling off languages without showing what you used them for. Be clear about which work your teammates owned.
Interviewer tipListen for a specific piece of code and its purpose on each project. A list of languages and project names leaves their programming work unclear.
Candidate tipPick two recent projects. For each, name the part of the application or script you worked on, the code you wrote or changed, and what it did when it ran.
Question 12: Tell me how you used code, documents and conversations to find the information that mattered for a programming change.
Example answerThe interviewer wants to see how you choose useful information from several sources before changing a program.
Use Situation, Task, Action, Result. Set up the programming change and the information gap. Name the sources you consulted, explain which details mattered to the requirements, and end with the effect on your code or tests.
Sample answer: "A spec asked me to add a late fee to overdue invoices but did not explain partial payments. I checked the billing code, the policy document and the business analyst's explanation. I set aside code for closed accounts because this change covered open invoices. The remaining sources still left a gap, so I sent the analyst examples of the different fee outcomes. The analyst confirmed the intended rule, and I used those examples in the tests."
Avoid listing sources without explaining their relevance, treating old code as the final authority, or guessing when the requirement remains unclear.
Interviewer tipA strong example compares sources and explains which details mattered to the programming change. Gathering documents without judging their relevance is a weak answer.
Candidate tipUse a real programming change. Name the sources you consulted, explain which details mattered to the requirements, and show how your choices shaped the code or tests.
Question 13: Share an example of a test you ran that helped you make a program more reliable.
Example answerThe interviewer wants to see whether you can design a test that exposes a reliability problem and verify that your change addresses it.
Pick one test and explain what led you to run it. Describe the inputs, the expected behavior and what actually happened. Say what you changed because of the result and what you saw when you repeated the test.
"I was testing a program that imported inventory files. I took a small sample and added an empty row between valid records because the files sometimes had blank lines. I expected the import to skip that row and finish. Instead, it stopped and left the rest of the file unread. I changed the reader to skip blank rows and ran the same file again. I checked that every valid record was imported and added the sample to our automated tests."
Avoid using a passing test as your entire example. Don't claim the fix worked without saying how you checked it.
Interviewer tipListen for a test that exposed a specific failure and a rerun that showed the fix worked. Disabling the failing test without fixing the problem is a red flag.
Candidate tipName the input or condition that exposed the failure, the fix you made, and the result when you ran that case again. If you kept the test to catch the same failure later, say so.
Question 14: Share an example of how you made sure a change to a shared data field was consistent everywhere the application used it.
Interviewer tipListen for how they tracked down uses of the field and checked that the change reached them. Assuming reports were unaffected without checking whether they used the field is a red flag.
Candidate tipPick one field you changed. Explain how you found where it was used, such as on a form or in a report, and what your checks showed.
Question 15: Give an example of how you turned the branches in a workflow diagram you drew into code.
Interviewer tipListen for a clear link between a decision in the diagram and the paths the code can take. Leaving out a branch the workflow calls for is a red flag.
Candidate tipPick one decision in the diagram and describe how you coded and checked each path from it. A course project or capstone works if you drew the diagram and wrote the code.
Question 16: Tell me about a time you spotted a problem in a program's output, logs or error reports before users did.
Interviewer tipListen for what they were watching, what made them notice, and how they confirmed and fixed the issue. Ignoring warnings until users complained is a red flag.
Candidate tipExplain what you were reviewing and what looked wrong. Describe how you checked the cause, what you did about it, and whether you added anything to catch it sooner next time.
Question 17: Describe your approach when a program you write has to process a very large volume of records.
Interviewer tipA strong answer covers testing with realistic data volumes, efficient queries or batching, and checks that no records were lost. Never having considered speed or data volume is a red flag.
Candidate tipUse a real example. Explain how you handled memory, speed and errors, how you tested with realistic data, and how you confirmed the output was complete and correct.
Question 18: Walk me through how you prioritize when bug fixes, change requests and new programming work all land on you at once.
Example answerThe interviewer wants to see how you decide what to work on when everything seems urgent, and whether you keep others informed. Explain your general method, then back it up with a recent example. Sample answer: "I sort work by impact and deadline. A bug that stops users from working comes first, then work with a fixed date, then smaller changes. When two requests compete and I'm not sure which matters more, I ask my lead rather than guess. Recently I was midway through a new feature when a bug stopped orders from saving. I paused the feature, fixed and tested the bug the same day, then told my lead the feature would be a day late and asked whether a small change request could wait until the following week. They agreed, and everything shipped in that order." Pitfalls to avoid: saying you just work harder or longer; treating every request as top priority; leaving your manager out when plans change.
Interviewer tipA strong answer weighs impact and urgency and checks priorities with the lead or manager. Working tickets strictly in arrival order, or never pushing back, is a red flag.
Candidate tipExplain the method you use, such as ranking by impact on users and by deadline, and give a recent example. Mention how you keep your lead informed when priorities change.
Question 19: Tell me about a time you had to tell a manager or client that a program would miss its deadline or had a serious bug.
Example answerThe interviewer wants to know whether you raise bad news early and honestly, and whether you bring options along with the problem. Use Situation, Task, Action, Result. Sample answer: "Two weeks before a release, I found that the data conversion I was writing would take much longer than planned, because the old records had far more errors than expected. I told my manager that day rather than hoping to catch up. I explained what I had found, showed a few examples of the bad records, and offered two options: move the date, or release with the clean records converted and fix the rest in a second pass. My manager chose the second option and explained the plan to the client. The release went out on time, and the second pass finished a few weeks later." Pitfalls to avoid: waiting until the deadline to speak up; blaming teammates or the client; bringing the problem with no ideas for what to do next.
Interviewer tipLook for early, honest notice with the facts, the impact and some options. Hiding the problem until the deadline, or blaming teammates, is a red flag.
Candidate tipSay what the news was, when and how you raised it, and what options you offered, such as a smaller scope or a fix plan. End with how the people involved responded.
Question 20: Tell me how you worked with an operations teammate or systems analyst to get a program running again after a scheduled run failed.
Example answerThe interviewer wants to see how you coordinate with operations or a systems analyst to restore a scheduled run and confirm it recovered.
Choose a failed run and explain what the program was meant to produce. Say what your teammate could see, what you checked in the program and how you agreed it was ready for another run. Describe how you verified the result together.
"A nightly report stopped before it produced its output. My operations teammate sent me the run log and confirmed the expected input file had arrived. I compared it with the previous day's file and found that a column header had changed. The report had stopped before writing anything. I updated the reader and checked both header versions with sample files. Operations restarted the job, and I checked the new report against the input before they marked the run complete."
Avoid retelling the incident without explaining the handoff. Don't assume a successful restart means the output is correct.
Interviewer tipListen for what each person contributed and how they confirmed that the next run worked. A red flag is calling the problem fixed without checking the new run.
Candidate tipBriefly describe the failed run, then say what your teammate saw in the run log and what you checked in the code. Finish with how you confirmed together that the program was working again.
Question 21: Share an effective method you have used to ensure that networks, workstations, central processing units, and peripheral equipment respond to programs' instructions.
Question 22: Describe an effective method you have used to maintain and control the use of computer systems software.
Question 23: Share an experience in which your contribution to the development of instructions for end users benefited your company.
Question 24: Describe a time when looking more closely at users' needs changed how you planned to build a feature.
Interviewer tipA strong answer connects a specific user need to a change in the feature design. Watch for a candidate who treats a guess about what users need as a confirmed requirement.
Candidate tipStart with the requirement you were given and the user need it left unclear. Explain the design choice you made once you understood that need and what the change let users do.
Question 25: Provide a time when you were able to identify a complex problem, evaluate the options, and implement a solution. How did the solution benefit your employer?
Example answerThe interviewer wants to see how you handle problems with many parts: how you break them down, choose a path, and follow through.
Use Situation, Task, Action, Result. Explain why the problem was complex, such as several causes or many people affected. Walk through how you found the root cause, the options you weighed, and how you put the solution in place. End with the benefit to your employer.
Sample answer: "Our monthly billing kept going out late. The cause wasn't one thing: data arrived late from two departments, and the billing software needed manual fixes. I mapped each step, timed them, and found the manual fixes took the most time. I compared hiring temporary help with automating the fixes, and we chose automation with help from our technology team. Billing went out on time for the next three months, and customers paid faster."
Pitfalls: Don't pick a simple problem and call it complex. Avoid skipping the options you considered. Don't take credit for others' work; name who helped.
Question 26: Share an experience in which your ability to consider the costs or benefits of a potential action helped you choose the most appropriate action.
Example answerThe interviewer wants to see that you think through the trade-offs of a decision before acting.
Use Situation, Task, Action, Result. Describe the decision, the options, and the costs and benefits you weighed, including money, time, risk, and the effect on people. Explain which you chose and how it turned out.
Sample answer: "Our team's printer broke for the third time in a year. One option was another repair, which was cheap. Another was a new printer, which cost more up front. I looked at the past year's repair bills and the downtime each breakdown caused. The repairs plus lost time were likely to cost more than a new machine over two years. I shared that with my manager, we bought a new printer, and we haven't had a breakdown since."
Pitfalls: Don't focus only on money; include time and people. Avoid a decision you made without checking the facts. Don't skip how it turned out.
Question 27: Tell me about a time you found an unusual approach to a programming problem that the obvious solution couldn't handle.
Interviewer tipListen for why the usual solution failed and how they tested the alternative. Needless complexity without explanation, documentation or a plan for maintenance is a red flag.
Candidate tipDescribe the problem and why the standard approach didn't fit. Explain your idea, how you tested it, and what it meant for the program or its users.
Question 28: Provide an example of a time when you were able to demonstrate excellent listening skills. What was the situation and outcome?
Example answerThe interviewer wants evidence that you listen to understand, not just to reply, and that it makes a difference to your work.
Use Situation, Task, Action, Result. Show what careful listening looked like: letting the person finish, asking follow-up questions, and repeating back what you heard. The outcome should show that listening caught something you would otherwise have missed.
Sample answer: "A manager from another department asked for a monthly report and said they wanted it faster. Instead of starting right away, I asked what they used the report for. They mentioned twice that they only looked at two of the columns. I confirmed that with them, built a one-page summary of just those figures, and it took a third of the time to produce. They used the summary format from then on."
Pitfalls: Don't just describe yourself as a good listener without an example. Avoid an answer where you talk mostly about what you said. Don't leave out the outcome the question asks for.
Question 29: Share an experience in which your understanding of a current or upcoming problem helped your company to respond to the problem.
Example answerThe interviewer wants to see that you keep up with what is happening around your work and use that knowledge to help the organization prepare.
Use Situation, Task, Action, Result. Explain what the problem was, how you came to understand it early (reading, training, talking with others), what you recommended, and how the organization responded.
Sample answer: "I read in an industry newsletter that a key supplier planned to stop making a part we used in several products. I checked with our purchasing team, confirmed the news, and researched two replacement parts. I shared a short summary with my manager, and we ordered extra stock of the old part while we tested a replacement. When the supplier stopped production months later, we switched over without any delays to customers."
Pitfalls: Don't take credit for spotting something everyone already knew. Avoid a story where you noticed the problem but did nothing. Don't leave out how you learned about it.
Question 30: Provide a time when you worked in a rapidly evolving workplace. How did you deal with the change?
Example answerThe interviewer wants to know how you respond when processes, tools, or priorities change quickly, and whether you help or slow things down.
Use Situation, Task, Action, Result. Describe what was changing and how it affected your work. Then explain what you did to adjust: learning the new way, asking questions, or helping others through it. End with how things turned out and what you took from it.
Sample answer: "In one year my team changed its scheduling software, its reporting process, and its manager. When the new software came in, I signed up for the first training session, wrote a one-page guide for the steps we used most, and shared it with the team. Questions to our manager dropped within a couple of weeks, and I was asked to help test the next update."
Pitfalls: Don't complain about the changes or past leadership. Avoid saying you just went along with it; show what you actively did. Don't pick a change so small it doesn't show adaptability.
Interviewer tipMake sure the candidate is flexible.
Candidate tipShow that you can adapt.
New to interviews? Start with the common questions every interview asks →