Java / FAQ

Java Interview Questions

JDBC is an abstraction layer that allows users to choose between databases. JDBC enables developers to write database applications in Java without having to concern themselves with the underlying details of a particular database.

A Java virtual machine (JVM) is a process virtual machine that can execute Java bytecode.
Each Java source file is compiled into a bytecode file, which is executed by the JVM. Java was designed to allow application programs to be built that could be run on any platform, without having to be rewritten or recompiled by the programmer for each separate platform.

Java has two types of exceptions: checked exceptions and unchecked exceptions.
Unchecked exceptions do not need to be declared in a method or a constructor’s throws clause if they can be thrown by the execution of the method or the constructor, and propagate outside the method or constructor boundary.

The servlet is a Java programming language class used to process client requests and generate dynamic web content.
Servlets are mostly used to process or store data submitted by an HTML form, provide dynamic content, and manage state information that does not exist in the stateless HTTP protocol.

The Java Runtime Environment (JRE) is the Java Virtual Machine (JVM) where your Java programs are being executed. It also includes browser plugins for applet execution.

Applets are executed within a Java-enabled browser.
Java application is a standalone Java program that can be executed outside of a browser.
However, they both require the existence of a Java Virtual Machine (JVM). Furthermore, a Java application requires a main method with a specific signature, to start its execution.

A Java Server Page (JSP) is a text document that contains two types of text:
static data and JSP elements.
Static data can be expressed in any text-based format, such as HTML or XML. JSP is a technology that mixes static content with dynamically generated content.

A Java Applet is a program that can be included in an HTML page and be executed in a Java-enabled client browser. Applets are used for creating dynamic and interactive web applications.

These methods can be used as a hint to the JVM, to start a garbage collection. However, it is up to the Java Virtual Machine (JVM) to start the garbage collection immediately or later.

What are the different types of Directives available in JSP? Directives are instructions that are processed by the JSP engine when the page is compiled to a servlet. Directives are used to set page-level instructions, insert data from external files, and specify custom tag libraries.

There are several differences between HashMap and Hashtable in Java:
Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.

Java provides and supports the creation both of abstract classes and interfaces. Both implementations share some common characteristics, but they differ in the following features:

The eight primitive data types supported by the Java programming language are:

byte, short, int, long, float, double, boolean, char

The main difference between them is that a Process is a program which is executing some code and a Thread is an independent path of execution in the process.

A process can have more than one thread for doing independent tasks e.g. a thread for reading data from disk, a thread for processing that data, and another thread for sending that data over the network.