Top 27 Java J2ee Architect Interview Questions
Q1. What Are New Features Introduced With Java eight ?
Lambda Expressions , Interface Default and Static Methods , Method Reference , Parameters Name , Optional , Streams, Concurrency.
Q2. Difference Between Factory And Strategy Design Pattern ?
Factory is a creational design sample whereas Strategy is behavioral design sample. Factory revolves across the advent of object at runtime whereas Strategy or Policy revolves across the choice at runtime.
Q3. What Are Various Types Of Class Loaders Used By Jvm ?
Bootstrap - Loads JDK internal lessons, java.* programs.
Extensions - Loads jar files from JDK extensions listing - normally lib/ext listing of the JRE
System - Loads classes from machine classpath.
Q4. What Is The Best Practice Configuration Usage For Files - Pom.Xml Or Settings.Xml ?
The first-class exercise guideline between settings.Xml and pom.Xml is that configurations in settings.Xml ought to be unique to the present day consumer and that pom.Xml configurations are unique to the challenge.
Q5. What Is Metaspace ?
The Permanent Generation (PermGen) space has completely been eliminated and is sort of changed by means of a brand new area known as Metaspace. The outcomes of the PermGen removal is that manifestly the PermSize and MaxPermSize JVM arguments are ignored and you may in no way get a java.Lang.OutOfMemoryError: PermGen blunders.
Q6. Can You Provide Some Implementation Of A Dictionary Having Large Number Of Words ?
Simplest implementation we are able to have is a List in which we will location ordered phrases and hence can perform Binary Search.
Other implementation with better search performance is to use HashMap with key as first man or woman of the phrase and price as a LinkedList.
Further level up, we can have related Hashmaps like ,
hashmap
a ( key ) -> hashmap (key-aa , value (hashmap(key-aaa,cost)
b ( key ) -> hashmap (key-ba , value (hashmap(key-baa,fee)
....................................................................................
Z( key ) -> hashmap (key-za , price (hashmap(key-zaa,value)
upto n levels ( in which n is the common length of the phrase in dictionary.
Q7. What Is Permgen Or Permanent Generation ?
The reminiscence pool containing all the reflective statistics of the java virtual device itself, which include elegance and approach items. With Java VMs that use magnificence records sharing, this generation is split into read-best and study-write areas. The Permanent technology consists of metadata required by the JVM to describe the training and strategies used in the utility. The everlasting technology is populated by using the JVM at runtime based on instructions in use by means of the utility. In addition, Java SE library classes and techniques may be stored here.
Q8. If You Are Given A Choice To Implement The Code To Either Insert A Record Or Update If Already Exist, Which Approach Will You Follow ?
In first case, there might be 2 DB calls in worst case and 1 in fine case. In second method there might be always 2 DB calls.
Decision at the approach must depend upon the subsequent issues -
@How high priced is the decision to DB. Are we the use of indices , hibernate and so on
If calls to DB are pricey , 1st approach should be the choice.
@Exception Book retaining load upon exception.
The benefit of saving 1st call in approach 1 must be larger than the Book preserving for the exception.
@Probability of the exception in first apparoach.
If the DB Table is nearly empty, it makes sense to follow Approach 1 as majority of the first calls will skip through with out exception.
Q9. Difference Between Adapter And Facade ?
The Difference between these patterns in simplest the intent. Adapter is used because the gadgets in present day shape can not speak wherein as in Facade , even though the objects can communicate , A Facade item is positioned among the consumer and subject to simplify the interface.
Q10. What Is Database Deadlock ? How Can We Avoid Them?
When multiple external sources are seeking to get entry to the DB locks and runs into cyclic wait, it may makes the DB unresponsive.
Deadlock may be avoided using style of measures, Few listed under:
Can make a queue in which we will verify and order the request to DB.
Less use of cursors as they lock the tables for long time.
Keeping the traction smaller.
Q11. Difference Between First Level And Second Level Cache In Hibernate ?
First degree cache is enabled through default whereas Second degree cache needs to be enabled explicitly.
First level Cache got here with Hibernate 1.Zero while Second stage cache got here with Hibernate 3.@
First degree Cache is Session unique while Second stage cache is shared with the aid of classes that is why First stage cache is taken into consideration nearby and second stage cache is taken into consideration international.
Q12. What Things You Would Care About To Improve The Performance Of Application If Its Identified That Its Db Communication That Needs To Be Improved ?
Query Optimization ( Query Rewriting , Prepared Statements )
Restructuring Indexes.
DB Caching Tuning ( if the use of ORM )
Identifying the issues ( if any ) with the ORM Strategy ( If the usage of ORM )
Q13. Why Web Services Use Http As The Communication Protocol ?
With the arrival of Internet, HTTP is the most favored way of communication. Most of the clients ( web skinny purchaser , web thick customers , cellular apps ) are designed to speak the use of http only. Web Services the use of http makes them on hand from sizeable style of purchaser applications.
Q14. Should We Create System Software ( E.G Operating System ) In Java ?
No, Java runs on a digital system known as JVM and hence would not embed nicely with the underlying hardware. Though we will create a platform impartial device software program but that could be simply sluggish and that is what we would in no way want.
Q15. What Are The Ways To Avoid Lazyinitializationexception ?
Set lazy=fake inside the hibernate config record.
Set @Basic(fetch=FetchType.EAGER) at the mapping.
Make certain that we're accessing the structured objects before closing the session.
Using Fetch Join in HQL.
Q16. Difference Between Builder And Composite ?
Builder is a creational Design Pattern while Composite is a structural layout pattern. Composite creates Parent - Child family members among your gadgets at the same time as Builder is used to create institution of gadgets of predefined kinds.
Q17. What Are The Different Types Of Memory Used By Jvm ?
Class , Heap , Stack , Register , Native Method Stack.
Q18. Why Using Cookie To Store Session Info Is A Better Idea Than Just Using Session Info In The Request ?
Session data inside the request can be intercepted and as a result a vulnerability. Cookie can be study and write via respective domain best and make sure that proper consultation records is being passed by using the consumer.
Q19. How Does Volatile Affect Code Optimization By Compiler?
Volatile is an coaching that the variables may be accessed by more than one threads and consequently should not be cached. As unstable variables are never cached and for this reason their retrieval cannot be optimized.
Q20. What Things Should Be Kept In Mind While Creating Your Own Exceptions In Java?
All exceptions have to be a infant of Throwable.
If you want to write down a checked exception this is automatically enforced by means of the Handle or Declare Rule, you need to increase the Exception elegance.
You want to put in writing a runtime exception, you need to increase the RuntimeException elegance.
Q21. Difference Between Proxy And Adapter Design Patterns ?
Adapter item has a distinctive enter than the real concern whereas Proxy object has the equal enter because the real problem. Proxy item is such that it must be positioned as it's far in location of the actual problem.
Q22. Which Uml Diagrams You Usually Use For Design ?
Use Case Diagram, Component Diagram for High level Design and Class Diagram , Sequence Diagram for low level design.
Q23. Shall We Use Abstract Classes Or Interfaces In Policy / Strategy Design Pattern ?
Strategy deals only with decision making at runtime so Interfaces have to be used.
Q24. What Would You Do If You Have To Add A Jar To The Project Using Maven ?
If its already there in Maven neighborhood repository, We can upload that as a dependency inside the task pom document with its Group Id, Artifact Id and version.
We can offer additional characteristic SystemPath if its unable to discover the jar within the local repository.
If its now not there in the local repository, we can deploy it first within the nearby repository and then can upload it as dependency.
Q25. How Do You Coordinate And Communicate With The Team Developers ?
We as a crew of developers , testers , analyst , lead and architect take a seat near each different. Most of the time I might just soar to their seat and talk to them ( if required ). We have each day stand up where we speak matters that needs team attention.
Q26. What Kind Of Software Architecture Your Organization Follow ?
We have multi tier structure with more than one layers , We have series of web servers and packages in utility tier, infrastructure libraries at middle tier and Database servers on the decrease tier. We are the use of Oracle as Database, ESB ( Enterprise service Bus ) for asynchronous communication and Rest Web Services.
Q27. What Are The Benefits Of Using Spring Framework ?
Spring allows developers to broaden employer-elegance programs using POJOs. The benefit of the use of only POJOs is that you do no longer want an EJB container product.
Spring is organized in a modular style. Even though the range of applications and instructions are significant, you have to fear best about ones you want and forget about the relaxation.
Spring does not reinvent the wheel as an alternative, it certainly uses a number of the prevailing technology like numerous ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, different view technology.
Testing an application written with Spring is straightforward due to the fact environment-dependent code is moved into this framework. Furthermore, by way of the use of JavaBean-fashion POJOs, it becomes less complicated to use dependency injection for injecting take a look at records.
Spring’s web framework is a nicely-designed internet MVC framework, which provides a notable opportunity to net frameworks consisting of Struts or other over engineered or much less popular web frameworks.
Spring affords a handy API to trlate technology-particular exceptions (thrown with the aid of JDBC, Hibernate, or JDO, as an instance) into regular, unchecked exceptions.
Lightweight IoC containers have a tendency to be lightweight, in particular while compared to EJB containers, for example. This is beneficial for developing and deploying programs on computer systems with confined memory and CPU sources.
Spring provides a constant traction control interface that could scale down to a neighborhood traction
