If you are an interviewee -- You have no control over what questions will be asked in Java job interviews, but there are a few Java interview questions that are very frequently asked in job interviews, and it really pays to prepare for those questions. Here are a few such questions. This is based on some of my recent interviews. Brushing up on these answers will boost your success rate in Java job interviews.
The focus is on judging your experience and technical strength. So, go through your resume and reflect back on your hands-on experience. Many of these answers will also serve you well in selling your technical strengths to open ended questions like -- tell me about yourself? , why do you like software development?, when reviewing others' work, what do you look for?, what was your most significant accomplishment?, etc
Q1. Can you describe the high level architecture of the application that you had worked on recently? or Can you give a 100 feet bird's eye view of the application you were involved in as a developer or designer?
A1. The purpose is to judge your overall experience. Here are a few links that will prepare for this most sought-after question, especially for the experienced professionals.
- 3 to n-tier enterprise Java architecture, the MVC-2 design pattern, the distinction between physical and logical tiers, and the layered architecture.The logical tiers shown in the diagrams for the above link are basically layers, and the layers are used for organizing your code. Typical layers include Presentation, Business and Data – the same as the traditional 3-tier model. But when talk about layers, we’re only talking about logical organization of code. Physical tiers however, are only about where the code gets deployed and run as war, ear or jar. Specifically, tiers are places where layers are deployed and where layers run. In other words, tiers are the physical deployment of layers.
- high level architectural patterns and the pros and cons of each approach. Discusses a number different architectual styles like MVC, SOA, UI Component, RESTful data composition, HTML data composition, Plug-in architecture, and Event Driven Architecture (EDA). Also, covers a sample enterprise architecture, which is a hybrid of a number of architectural styles.
- Single page web design. A single rich web page loading different sections (e.g tabs) of the page by making different ajax calls to relevant RESTful web services to get the JSON data to render the relevant sections.
- Understanding of various types of application integration styles. Enterprise applications need to be integrated with other systems, and this post covers different integration styles like sharing the same database, feed based, RPC style (e.g. web services), and exchanging JMS messages.
Q2. How would you go about deciding between SOAP based web service and RESTful web service?
A2. Web services are very popular and widely used to integrate disparate systems. It is imperative to understand the differences, pros, and cons between each approach. Recently, I have been asked these questions very frequently, here is the answer that discusses the pros and cons of SOAP vs. RESTful web services in detail.
Q3.How will you go about ensuring that you build a more robust application? or How do you improve quality of your application?
A3. This question is very popular with the interviewers because they want to hire candidates who write good quality application. Here are some useful links to prepare for this question.
- Java interview questions and answers on code quality. Gives a high level over view as to things you can do and tools you can use to improve code quality. A common popular job interview question answered is -- What is the difference between fake objects, mock objects, and stubs?
- Unit testing with mock objects interview questions and answers. Tutorial that explains how to write JUnit tests with mock objects using the Mockito and Power mock frameworks.
- Java Interview Questions and Answers - performance testing your Java application. A high level overview as to how you can go about monitoring performance. Many applications face performance issues and this is a very popular question with the interviewers.
- Know the SDLC and the best practices. Gives a high level overview of SDLC.
Q5: Can you write code? How would you go about implementing .....?
A5: You will be asked to write a small function or a program. The interviewer will be looking for things like
- How well you analyze the requirements and the solution? Ask relevant questions if the requirements are not clear. Think out loud so that the interviewer knows that how you are approaching the problem.The approach is more important that arriving at the correct solution.
- List all possible alternatives.
- Write pseudo code.
- Write unit tests.
- Where required, brainstorm with the interviewer.
- Find ways to improve your initial solution. Talk through thread safety and best practices where applicable.
- Java coding interview questions and answers:. Covers a number of coding questions with answers. These are some of the popular coding interview questions like reversing a string, calculating the Fibonacci number, recursion vs iteration, equals versus ==, etc.
- Printing 1 to 10 in order with 2 separate threads. One thread prints odd numbers and the other thread prints even numbers.
- How will you flatten a pre-order tree structure in Java using both recursion and iteration?
- Can you create a Tree class that can work with different types like String, File, Person, etc and supports the following methods
1. It should be flexible enough to convert from Recursion to iteration if required.
2. Computation will initially be "addition", but should be extendable to multiplication, subtraction, etc.
3. Should handle integers and floating point numbers.
4. Make use of generics.
A. Java coding with recursion and generics
Q. The SimpleDateFormatter and DecimalFormatter are not thread-safe. How will you use them in a thread-safe manner?
A. Using the ThreadLocal class as demonstrated in this tutorial.
Q. If Java did not have its own Map or Set implementation, how will you go about implementing your own?
A. Covered in detail with diagrams and code in "Core Java Career Essentials" book.
Java Interview Questions 6 - 10 for experienced developers
Java Interview Questions 11 - 16 for experienced developers
Java Interview Questions 17 - 20 for experienced developers