Java Interview Question
Question 1
What are the differences between JDK, JVM, and JRE?
What are the differences between JDK, JVM, and JRE?
Java Virtual Machine (JVM) provides the necessary runtime environment for the executable java bytecodes.
Whereas, Java Runtime Environment (JRE) contains some important sets of files that are required by JVM in the runtime environment.
JDK (Java Development Kit) should be seen as a benefactor of JRE since it constitutes along with the development tools and JRE, which is crucial to execute and write a program.
Question 2
What is JSON?
Question 3
What is the content negotiation in Java?
Here the client specifies the notations as to what can be accepted from the host. As the server and client negotiate on the format and language of the content, this process is called content negotiation.
Question 4
What is the abstract class and how does it work?
- If a particular class is incorporated with the abstract keyword in its declaration format, then it is an abstract class. It has both abstract and non-abstract methods with the body and varies in its methods.
- An abstract class may consist of private, public, protected variables that may be both constants and defaults.
- It is necessarily extended and the inherent methods are implemented.
- A class must be declared abstract even if that class has at least a single abstract method.
Question 5
What is transient in Java?
Question 6
Explain the volatile variables?
Question 7
Explain the processes HTTP Tunneling?
Question 8
Differentiate abstract classes and interfaces?
Abstract Class | Interfaces |
---|---|
An Abstract class provides default and complete code for the exact details that have to be overridden. | But an interface does not provide any code other than the signature. |
In the event of an abstract class, a class extends just a single abstract class. | Here a Class implements multiple interfaces at a given time. |
An abstract class would contain also non-abstract methods. | The entire set of methods of an Interface are only abstract. |
An abstract class can have all the public, private, protected visibilities. | An Interface visibility should be only public or none. |
An abstract class contains constructors. | An Interface is completely devoid of constructors. |
Question 9
What is method overloading?
- Method Overloading is a process where Methods of the similar class shares the similar name. But here each method contains a different number of parameters or the parameters have various order and types.
- Method Overloading is mainly used to extend or add more elements to the behavior of the method.
- In its inherent settings, it is a compile-time polymorphism.
- The methods should contain a different signature.
Question 10
What is aggregation in Java?
Question 11
Describe the servlet?
- Java Servlet is a set of server-side technologies that extend the abilities of web servers by lending them the necessary support to respond dynamically and the endurance of data.
- We can write our own servlets with the interfaces and classes of javax.servlet and javax.servlet.http packages.
- All servlets must be implemented with the javax.servlet.Servlet interface, because it alone defines servlet lifecycle methods. The GenericServlet class given with the Java Servlet API also can be extended when a generic service is implemented in the first place.
- If we are to handle HTTP-specific services, we do have doGet() and doPost() provided by the HttpServlet class.
Question 12
What is session management in servlets and explain?
Here are the usual methods of session management in servlets:
1.User Authentication
2.Rewriting the URL
3.Session Management API
4.Cookies
5.HTML Hidden Field
Question 13
Explain in detail the JDBC Connection interface?
Question 14
How does Hibernate Framework work?
Question 15
What is a difference between Error and Exception?
While exceptions are conditions that occur because of bad input or human error etc. e.g. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference. In most of the cases it is possible to recover from an exception (probably by giving the user a feedback for entering proper values etc.