Java Design Interview Questions

  1. As an programmer, what are design principles you focus on?
  2. What are the modern programming practices which lead to very good applications?
  3. What are the typical things you would need to consider while designing the Business Layer of a Java EE Web Application?
  4. What are the things that you would need to consider when designing the Access Layer (Data Layer) of the web application?
  5. What are the things that you would need to consider when designing the Web Layer?
  6. What are the important features of IDE Eclipse?
  7. What are the best practices for build tool Maven?

As an programmer, what are design principles you focus on?

“Design

I start off with the 4 Principles of Simple Design. Following YouTube PlayListexplains the four principles of simple design in detail :

  • Runs all tests
  • Minimize Duplication
  • Maximize Clarity
  • Keep it Small

Next important design principles would be those related to Object Oriented Programming. Have good object, which have well-defined responsibilities. Following are the important concepts you need to have a good overview of. These are covered in various parts in this YouTube Video . Also, look up the specific videos for each topic.

UML is next even though, formal use of UML is on the way down with Agile. However, I think UML is a great tool in the arsenal for a white board discussion on design. A picture is worth thousand words. I recommend having a good overview of the UML basics. Focus on these four before you move on to others.

  • Class diagrams
  • Sequence diagrams
  • Component diagrams
  • Deployment diagrams

Last and also the least important is Design Patterns. This YouTube Video covers all the major design patterns . My personal view : Design Patterns are good to know. Have a good idea on what each one of them does. But, that where it ends. I’m not a big fan of understanding the intricate details of each Design Pattern. You can look it up if you have a good overall idea about Design Patterns.

What are the modern programming practices which lead to very good applications?

“Design

First of all : Unit Testing and Mocking. We are in the age of continuous integration and delivery, and the basic thing that enables those is having a good set of unit test in place. (Don’t confuse unit testing with screen testing done manually to check if the screen flow is right. What I mean by unit testing is JUnit test’s checking the business logic/screen flow in a java method (or) set of methods). Understand JUnit. This set of videos is a good start to understand JUnit. Also understand the concept of Mocking. When should we mock? And when we should not? Complicated question indeed. Understand atleast one mocking framework : Mockito is the most popular one. Easymock is a good mocking framework as well.

Second in line is Automated Integration Tests. Automated Integration Tests is the second important bullet in enabling continuous delivery. Understand Fitnesse, Cucumber and Protractor.

Third is TDD (actually I wanted to put it first). Understand what TDD is. If you have never used TDD, then be ready for a rude shock. Its not easy to change a routine you developed during decades (or years) of programming. Once you are used to TDD you never go back. I promise. This list of videos is a good start to understanding TDD. Have fun.

Next comes BDD. In my experience, I found BDD a great tool to enable communication between the ready team (Business Analysts, Product Owner) and the done team (Developers, Testers, Operations). When User Stories are nothing but a set of scenarios specified is GWT (Given When Then) format, it is easy for the done team to chew at the user story scenario by scenario. With tools like Cucumber & Fitnesse, tooling is not far behind too. Do check BDD out.

Next in line is Refactoring. IUnderstand refactoring. Understand the role of automation tests in refactoring.

Last (but not the least) in the line is Continuous Integration. Every project today has continuous integration. But, the real question is “What is under Continuous Integration?”. Compilation, unit tests and code quality gate(s) is the bare minimum. If you have integration and chain tests, wonderful. But make sure the build does not take long. Immediate feedback is important. If needed, create a separate build scheduled less frequently for slower tests (integration and chain tests). Jenkins is the most popular Continuous Integration tool today.

What are the typical things you would need to consider while designing the Business Layer of a Java EE Web Application?

Listed below are some of the important considerations

  • Should I have a Service layer acting as a facade to the Business Layer?
  • How do I implement Transaction Management? JTA or Spring based Transactions or Container Managed Transactions? What would mark the boundary of transactions. Would it be service facade method call?
  • Can (Should) I separate any of the Business Logic into seperate component or service?
  • Do I use a Domain Object Model?
  • Do I need caching? If so, at what level?
  • Does service layer need to handle all exceptions? Or shall we leave it to the web layer?
  • Are there any Operations specific logging or auditing that is needed?Can we implement it as a cross cutting concern using AOP?
  • Do we need to validate the data that is coming into the Business Layer? Or is the validation done by the web layer sufficient?

What are the things that you would need to consider when designing the Access Layer (Data Layer) of the web application?

  • Do we want to use a JPA based object mapping framework (Hibernate) or query based mapping framework (iBatis) or simple Spring DO?
  • How do we communicate with external systems? Web services or JMS? If web services, then how do we handle object xml mapping? JAXB or XMLBeans?
  • How do you handle connections to Database? These days, its an easy answer : leave it to the application server configuration of Data Source.
  • What are the kinos of exceptions that you want to throw to Business Layer? Should they be checked exceptions or unchecked exceptions?
  • Ensure that Performance and Scalability is taken care of in all the decisions you make.

What are the things that you would need to consider when designing the Web Layer?

  • First question is do we want to use a modern front end javascript framework like AngularJS? If the answer is yes, most of this discussion does not apply. If the answer is no, then proceed?
  • Should we use a MVC framework like Spring MVC,Struts or should we go for a Java based framework like Wicket or Vaadin?
  • What should be the view technology? JSP, JSF or Template Based (Velocity, Freemarker)?
  • Do you want AJAX functionality?
  • How do you map view objects to business objects and vice-versa? Do you want to have View Assemblers and Business Assemblers?
  • What kind of data is allowed to be put in user session? Do we need additional control mechanisms to ensure session size is small as possible?
  • How do we Authenticate and Authorize users? Do we need to integrated external frameworks like Spring Security?
  • Do we need to expose external web services?

What are the important features of IDE Eclipse?

Go through this YouTube PlayList. It takes you through all the important features of Eclipse.

What are the best practices for build tool Maven?

Use archetypes as much as possible. Archetypes are good start for generating projects (lookup : mvn archetype:generate) based on Spring, Spring MVC, Struts, Hibernate and a wide variety of other projects. Also, it is a good practice to create maven archetype for the components we create repeatedly (access components, consuming/exposing web services).

Some of the Maven Best Practices are

  • Proper Dependency Mgmt : Version for one dependency at one place - preferably in the parent pom.
  • Group related dependencies.
  • Exclude test dependencies from final ear.
  • Have a parent pom.
  • Use Profiles as needed.

If you loved these Questions, you will love our PDF Interview Guide with 400+ Questions.
Download it now!.

400+ Interview Questions in 4 Categories:
  1. Java : Core Java, Advanced Java, Generics, Exception Handling, Serialization, Threads, Synchronization, Java New Features
  2. Frameworks : Spring, Spring MVC, Struts, Hibernate
  3. Design : Design, Design Patterns, Code Review
  4. Architecture : Architecture, Performance & Load Testing, Web Services, REST Web Services,Security, Continuous Integration