Top 40 Advanced Java/J2EE Interview Questions Answers for Experienced - 3 to 5 Years

I have shared many posts about Java interview question in the past but nothing, particularly for support engineer perspective. Since there are a lot of L1 and L2 support job exists in BFSI (Banking, Finance, and Insurance Industry) and they are also for the longer term, I decided to write this post. When you go for a support engineer role, especially for Java application be it to core Java or Java EE application, Interviewer expects you know basics of Java and can start/stop the application, see log files, alert developers, and other aspects of the support e.g. opening conference bridge to solve production issues, communicating to stakeholders, and involving right peoples. In this article, I will share questions to help with technical aspects e.g. the essential skills you need to clear a support engineer interview.

Even though you will be interviewed to support Java application, it's expected from you to know SQL, UNIX, XML and other key technologies which you will use in your day-to-day job. In this post, you will find questions which are asked to check whether a candidate has required skills to support Java application or not.


39 Interview Questions for Java JEE Support Engineers

Here is my collection of some of the best interview questions for Java and JEE support professionals. If you are working in production services or supporting Java application, these interview question will help you to do well on your interview. If you moving from development to support role then also these questions will give you a good idea about what is expected from a Java JEE support engineers.

1) How do you check your Java process is running on Linux? (example)
You can check by using "ps" command and "grep" command e.g. ps -ef | grep "myprocess". The keyword which you use with grep for search can be anything unique to your process, something which appears in its command line e.g. name of the class which implements the main method. You can also do "ps -ef | grep java" to list all Java process.



2) How do you check how much memory and CPU your Java process is consuming?
First, you need to find the PID of your process, which you can find by using the "ps" command as shown in the previous question. Once you find the PID you can use the "top" command to find the CPU and memory usage. Alternatively, you can also use the prstat command as shown here.


3) What does -Xmx and -Xms parameters mean?
These are parameters to specify heap size in Java. The -Xms defines the size of the heap when JVM starts up and -Xmx is used to specify the maximum heap size for Java application i.e. your heap cannot grow beyond that and JVM will die by throwing OutOfMemoryError if your heap doesn't have enough space to create new objects. See here to learn more about heap memory in Java.


4) What is the difference between JVM and JRE?
The JRE stands for Java Runtime Environment and JVM stands for Java Virtual Machine. You install JRE to run Java application e.g. Applet or Core Java application or Web server like Tomcat. The JVM is part of JRE. See here to learn more differences between JVM and JRE.


5) What is the difference between JVM and JIT? (answer)
The JVM stands for Java Virtual machine while JIT stands for Just in time Compiler. The JIT is part of JVM and used to convert the Java bytecode into native machine code which runs faster. There is some threshold set if a code runs more than the threshold it becomes the candidate of just in time compilation by JIT.



6) How do you take the heap dump of a Java process? 
There are many ways to take the heap dump of a Java process e.g. Tomcat, but most common is by using tools available in JDK e.g. jVisualVM, jCmd, and jmap. Here is the command you can use to take the heap dump of Java process:

$ jmap -dump:live, file=/location/of/heap_dump.hprof  PID

The heap dump will contain all live objects and they are stored in heap_dump.hprof file. Remember, you also need PID of Java process which you can find by using "ps" and "grep" command as discussed in the first question. You can see Java Performance Companion by Charlie Hunt to learn more about taking and analyzing heap dump in Java to find memory leak and other memory related errors. 



7) How do you take a thread dump of a Java process?
Taking thread dump is easier than taking heap dump because you don't need to remember tool. In Linux, you can just use the kill command to take the thread dump e.g.

$ kill -3 PID 

will print the thread dump in the log file or where System.out is redirected. Similarly, in Windows, you can use Ctrl + Break from the command prompt. Alternatively, you can also use jConsole and VisualVM to take the thread dump of Java application in both Windows and Linux. You can also read Java Performance The Definitive Guide By Scott Oaks to learn more about thread dump and heap dump.



8) What is OutOfMemoryError in Java? How do you deal with that?
The Java virtual machine throws java.lang.OutOfMemoryError when there is not enough memory to run the application e.g. no more memory to create new objects, no more memory to create new threads etc. The most common OutOfMemoryError is the java.lang.OutOfMemoryError: java heap space, which comes when there is no more memory left to create a new object.


9) What is the difference between 32-bit and 64-bit JVM? (answer)
The main differences between 32-bit and 64-bit JVM are that later is designed for 64-bit operating system e.g. Windows 8 or later versions of Linux. From Java developer's perspective, the main difference between them comes from heap size. A 64-bit JVM virtually has unlimited heap memory as compared to 4GB of the theoretical limit of 32-bit JVM. If your program needs more memory, better run it on 64-bit JVM with large heap space. See here to learn more about 32-bit and 64-bit JVM.



13) What is Garbage Collector? (answer)
The garbage collector is a component of Java virtual machine which is responsible for reclaiming memory from dead objects. It's one of the key components and allows an application developer to focus on application development rather than doing memory management. Some of the popular garbage collectors are a Concurrent Mark-Sweep garbage collector and G1 garbage collector in recent times.


14) How do you analyze a heap dump?
There are many tools to analyze heap dump in Java e.g. you can use the jhat tool which comes along with JDK. You can also use Eclipse Memory Analyzer to analyze heap dump to find out any memory leak in Java while dealing with OutOfMemoryError in Java. See Java Performance The Definitive Guide By Scott Oaks to learn more about analyzing Java Heap dump.

Java and JEE Interview Questions and answers



15) What is the difference between Web Server and Application Server? (answer)
The main difference between Web and Application Server comes from the fact that you cannot run EJB on the Web server like Tomcat or Jetty. The application server like WebLogic and WebSphere provides the runtime environment for EJB and other advanced services required by Java EE or J2EE specification.


16) What is the difference between Apache httpd and Tomcat?
Though both httpd and Tomcat are products of Apache software foundation, the httpd is more popular and used across the web and not just in Java world. The httpd is a web server which can serve static HTML files and dynamic content using PHP, Perl or Python, while Tomcat is a Servlet container which provides the runtime environment for Servlet and JSP. You can also use both Apache httpd and Tomcat together in Java world.


17) Can you use Apache and Tomcat together?
Yes, you can use Apache and Tomcat together. There are many Java web application which is fronted by Apache web server to deliver static resources e.g. HTML files, images, configuration files etc. You can then configure Apache to forward the request to Tomcat.


18) How do you start and stop Tomcat in Linux?
When you install Tomcat in Linux by unzipping the downloaded package, you can see that there is a startup.sh and shutdown.sh file in the tomcat/bin directory. These scripts are used to start and stop Tomcat in Linux. These scripts internally call Catalina.sh, the main script to start Tomcat engine.



19) How do you start and stop Apache in Linux?
The Apache server runs as httpd daemon in Linux and you can either use kill command after finding the PID of httpd process as shown here or you can use the apachectl script as shown below to start and stop Apache web server in Linux

Starting Apache web server in Linux

$ apachectl start

Stopping Apache web server in Linux

$ apachectl stop

Restarting Apache web server in Linux

$ apachectl restart
or:
/sbin/service httpd restart

You might need root access to do if Apache web server is not running on your application account.


20) What is JDBC?
The JDBC stands for Java Database connectivity and it provides API to connect a database from Java programs. Different Java vendors e.g. MySQL, Oracle, Microsoft SQL Server, PostgreSQL they implement the API and provides their driver implementation to allow Java to connect to their database. Since almost every enterprise application has a database, JDBC is very important for any real world projects.


21) What is the difference between JDBC and JNDI?
As I said in the previous answer, the JDBC stands for Java Database Connectivity and provides APIs and guidelines to connect a database from Java, while JNDI stands for Java Naming and Directory Interface and provides a logical structure for retrieving resources e.g. database, messaging queues, enterprise Java beans without knowing their physical place e.g. host or port. You can register a resource with JNDI and then rest of your application component can access them using JNDI name. The database connection pool is the most common resource accessed via JNDI in web servers like Tomcat or WebLogic.


22) What is database connection pool? (answer)
As it name suggests, it just a pool of database connections. Since creating a new database connection in real-time is an expensive process and can potentially slow down the response time, many application maintains a pool of active database connection. When a request comes in they retrieve a connection from the pool, get the data from the database and then return the connection back to pool so that it can be reused. This way, response time is improved in most of the Java web application. See here to setup a database connection pool in Tomcat using Spring framework.


23) Your Java application is connected to a Database via a connection pool. Suddenly your database goes down? Is that an issue with your Java application? Do you need to restart your Java application?

hint: Since your Java application is using a connection pool, it has active connections to database which will get disconnected once DB goes down. If you try to execute a query, you will receive Socket errors.



24) How do you send web service request from Linux? (answer)
There are some commands available in Linux e.g. curl and wget which allows you to send HTTP commands, which you can use to call and test your web services from Linux. Particular, Curl is used extensively to test RESTful Web Services because it can send POST request, GET request, request with headers and also authenticate using both basic and digest authentication.

If you are working with REST API, I suggest learning curl, it's very convenient to check if your API is working properly using curl from the command line. You can even write a script to automate those stuff.


25) What is the difference between HTTP and HTTPS? (answer)
This is one of the common and easy questions. Of course, you know the difference between HTTP and HTTPS right? well, HTTP is insecure but HTTPS is secure, the extra "s" is for security, which means it not only encode and encrypt the message before sending but also verify the identity of the server by using  SSL certificates provided by global certificate authorities e.g. GoDaddy, Thawte, VeriSign, Digicert, GeoTrust, and Comodo.  See here to learn more how SSL and Certifications work in Java web application.


26) What is the difference between the GET and POST method? (answer)
Another simple but frequently asked question on Java support interviews. The main difference between the GET and POST is that GET is both idempotent and safe but POST is not. You can fire GET request multiple time and it will give the same result but multiple POST submission should always be avoided. GET is also used to read data from server and POST is used to send data to the server.


27) What is the difference between Servlet and JSP? (answer)
This is another interesting Java JEE support Interview Question. Even though both Servlet and JSP is used to create dynamic HTML the key difference between them is their purpose. Servlet is meant for Java developers and you write more Java than HTML and that's why it serves as Controller in many popular MVC framework e.g. DispatcherServlet in Spring MVC.

On the other hand, JSP is designed for HTML developers and it's more HTML than Java and that's why it is used as "view" in MVC frameworks like Spring and Struts. See the link in the answer for more detailed comparison.



28) What is the difference between Struts and Spring MVC?
This is again a popular and frequently asked question on Java JEE Interviews. Even though both are popular web MVC framework for Java applications, the key difference is that Spring brings dependency injection first and Struts brings it later using Struts 2.0.

Spring is also a suite of libraries e.g. you get Spring Security to implement security in your application, then there is Spring Boot, Spring Data, Spring Cloud and many more useful libraries under Spring umbrella.

Java JEE Support Interview Questions



29) What is the difference between JDBC and Hibernate? (answer)
There are many differences between JDBC and Hibernate but the most important one is that JDBC provides an API to connect to the database and execute the query but Hibernate is an ORM (Object Relational modeling) framework, which means it allows you to work with objects while it takes care of saving and retrieving object from database.

In short, in JDBC you need to write SQL queries to get and store data from database but in Hibernate you just deal with objects, Hibernate takes care of issuing SQL queries to the database.


30) What is the difference between Stack memory and heap? Which one is faster? (answer)
These are just two different memory areas used to store different kinds of variables. The stack is local to every thread while heap memory is shared among all threads. Since Stack is closer to thread and usually implemented using CPU registers they are faster than heap memory. The stack is used to store local variables as well method call frames while heap is used to store objects and class metadata. See the detailed answer for more points.


31) What is the difference between TCP/IP and UDP protocol? (answer)
There are several differences between TCP and UDP protocol but the most important of them is that TCP provides a guarantee of message delivery while UDP doesn't give any guarantee. Because of this guarantee TCP sends more messages than UDP and hence consume more bandwidth and slower than UDP. TCP is also connection oriented protocol while UDP is connectionless. See the detailed answer for more points.

Java Support Engineer Interview Questions



32) Your Java application is connecting to another Java application (server) running on the remote host and listening on port 17865. Now, you don't have access to that remote host to go and see if the process is running. How do find if the server is up and running?
hint: you can use the telnet command



33) You are supporting a Java web application which connects to many core Java process and gets data from them to the distribution to clients? One client complains that the request for data is taking too long and it's almost like hung? How do you troubleshoot this problem?

hint: check the log, check database, check the file system


34) The Java application you support connects to a database via a DNS, which automatically switches to the secondary database server when the primary goes down. You find that in the event of a failover, your Java application is not connecting to secondary DB server? How do you troubleshoot this problem?

hint: check which version your Java application is running. Some JRE caches the DNS e.g. JRE 1.6

Java J2EE Interview Questions



35) What is a deadlock? How do you find if your Java program has a deadlock? (answer)
The deadlock is a condition which can occur between two or multiple threads. In this case, each of the thread waits for each other and cannot progress. In Java, this usually happens when thread 1 holds the lock required by thread 2 and thread 2 holds the lock required by thread 1. If your Java program is hung then it could be a deadlock. You can take a thread dump and find out if any thread is waiting for the lock hold by other and vice-versa. You can also use jConsole tool to find deadlock.


36) What is the race condition? (answer)
The race condition is another multithreading and concurrency bug which happens due to racing between two threads, for example, if one thread is updating a variable and second thread tries to read the value before it finished. You can avoid race conditions by properly synchronizing your code.


37) What is the difference between PATH and CLASSPATH? (answer)
Both are key environment variable used by Java platform, but the key difference between them is that PATH points to the JDK binaries or native libraries e.g. java.exe, while CLASSPATH points to Java binaries e.g. JAR files, which contains bytecode. PATH is also system level concept independent of Java but CLASSPATH is purely Java concept and used by JVM to load classes required by Java application you are running.


38) How do you find the Java version used by your application? (answer)
You can run the java -version command in the command prompt to find out the version of Java used by your application. If you have multiple JDK or JRE installed then make sure you use the one which is used by your application.


39) What is JAVA_HOME environment variable? (answer)
The JAVA_HOME is nothing but a user defined environment variable which points to the installation directory of JDK. For example, if you have installed JDK in /opt/jdk_1.6_20 in Linux then the JAVA_HOME variable will point to this directory. Same goes for Windows or any other operating system.


That's all about 39 essential questions fro Java JEE Support Engineer. It's just a small set of questions you can expect in any service based company or investment banks but does remember to prepare key skills required for support engineers e.g. UNIX, SQL, Java, and others. In the next part of this article, I will share some of the frequently asked questions from Java Support Engineer on SQL, UNIX, and other supporting technologies.


Other topic based Java Interview questions for more practice
  • 21 Java Inheritance Interview Questions and Answers (list)
  • 15 Data Structure and Algorithm Questions from Java Interviews (read here)
  • Top 10 Spring Framework Interview Questions with Answers (see here)
  • Top 20 Hibernate Interview Questions and Answers (list)
  • 10 JDBC Interview Questions for Java Programmers (questions)
  • 15 Java NIO and Networking Interview Questions with Answers (see here)
  • 20 Java Design Pattern Questions asked on Interviews (see here)
  • 10 Struts Interview Questions for Java developers (list)
  • 30 OOP Interview Questions with Answer (see)
  • 19 Method overloading and overriding interview questions (see here)
  • 10 frequently asked Servlet Interview Questions with Answers (see here)
  • 15 Java Enum based interview questions with answers (read)
  • 10 Oracle Interview Questions for Java developers (see here)
  • Top 10 JSP Questions  from J2EE Interviews (read here)
  • 12 Good RESTful Web Services Questions from Interviews (read here)
  • Top 10 EJB Interview Questions and Answers (see here)
  • Top 10 JMS and MQ Series Interview Questions and Answers (list)
  • 10 Hibernate Interview Questions for Java EE developers (see here)
  • 21 Final modifier interview questions with answer (read)
  • 10 XML Interview Questions for Java Programmers (read here)
  • Top 10 XSLT Interview Questions with Answers (read more)
  • Top 10 Trick Java Interview Questions and Answers (see here)
  • Top 40 Core Java Phone Interview Questions with answers (list)

This list of Java interview questions for Java, JEE, and J2EE support engineers should be enough to prepare for any Java interview. You can crack both fresher and experience level interview by preparing these Java interview questions, at least first few rounds. If you face any other interesting question which is not in this list, then please let me know via comments and I'll add it.

Further Learning
Java Web Fundamentals By Kevin Jones
Introduction to Spring MVC


1 comment:

  1. Questions 10, 11 and 12 are missing for some reazon?

    ReplyDelete