Java Interview Questions and Answers - Part 4

The >> is right shift operator. It shifts bits towards right. For example: 5 >> 1 returns 2. It shifts one bit towards right and one bit is lost...
Anonymous Inner Classes - An inner class without a name. It allows the declaration of the class, creation of the object and execution of the methods in it at one shot...
In deep copy the copy operations would respect the semantics of the object. For example, copying an object along with the objects to which it refers to...
The variables that are initialized at run time is called as dynamic variable...
Java Transaction API is simple and more flexible to use. There are two levels in JTA API...
Usually all operating systems have limitations for using the number of file handles, sockets etc., which can be open...
Bootstrapping is a technique which activates more complex / complicated system of programs...
A java applet application, a web application can run without main method. A Java program can run without using ‘ public static void main(String args[]) ‘ method by using a static block...
Most of the web applications uses HTTProtocol. The user requests need to be received and processed through the HTTProtocol...
Filters are powerful tools in servlet environment. Filters add certain functionality to the servlets apart from processing request and response paradigm of servlet processing...
The tag is utilized for repeating the nested body content over a collection. Every element / object in a specified collection...
The differences are: The DataInputStream works with the binary data, while the BufferedReader work with character data...
The throw key word is used to explicitly throw an exception, while throws is utilized to handle checked exceptions for re-intimating the compiler that exceptions are being handled...
Object serialization could be used in different ways: - Simple persistence of the object...
The following are the similarities between an array and an ArrayList: - Both array and ArrayList can have duplicate elements in them...
A bean can be determined whether is a stateless or stateful by analyzing the deployment descriptor ejb-jar.xml...
The non-static block code is executed when a new class is instantiated. It executes before the constructor’s execution...
The elements of HashMap can be sorted by using the static method Collections.sort()...
A checked exception throws a block of code and represented by the throws keyword...
Runnable interface is always preferred because, the class implementing it can implement as many interfaces as a developer can, and also extend another class...
The prime difference is that pointers are to locate the address of the primitive variables only...
Jasper Report is a very popular open source reporting tool written in Java. The reports can be seen on the screen, on a printer...
Struts: Struts is a MVC pattern framework, Generating integration logic is done dynamically using Struts...
The following is the process: - Type jar –cvf <.java file(s)>...
Create an object of CrystalReport class. - Invoke aboutBox() method – for confirmation whether it is loaded properly - Establish the connection by using setConnect() method...
Java does not support multiple inheritances. To avoid ambiguity problem – Diamonds of Death – and complexity of multiple inheritance...
A private constructor is used when there is no requirement of another class to invoke that. It is used mostly in implementing singletons...
In order to make a class immutable, the changing state of the class object must be restricted. This means restricting an assignment to a variable...
Java methods are virtual by default. The virtual methods are the methods of subclasses...
First ,the interface is to be defined. Defining an interface is placing the method signatures...
A concrete class has concrete methods, i.e., with code and other functionality...
Deep cloning builds a new reference and a new object to refer to a new object...
The Applet tag has the following attributes...
An applet class file may present in any of the folder. The .class file name along with its current path...
To refresh a page in an applet window without flashing, the update() method is to be overridden...
Java interacts with database using an API called Java Database Connectivity. JDBC is used to connect to the database...
SQL Exception is associated with a failure of a SQL statement. This exception can be handled like an ordinary exception in a catch block...
DatabaseMetaData provides comprehensive information about the database...
ResultSetMetaData is a class which provides information about a result set that is returned by an executeQuery() method...
A CacheRowSet object is a container for rows, that ‘caches’ the rows in the memory...
A lock is a preventive software mechanism that other users can not use the data resource...
All the objects which are the instances of the sub class Observable, maintains a list of observers...
Synchronization is the process of allowing threads to execute one after another...
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered...
A task’s priority is an integer value. This value is used to identify the relative order of execution with respect to other tasks...
A single ampersand is used to perform ‘bit-wise AND’ operation on integer arguments. It constitutes the logical AND operator...
Event-delegation model has two advantages over event-inheritance model...
The wait() method makes the thread to halt, thus allowing other thread to perform...
An event-listener interface allows describing the methods which must be implemented...
To enable a particular event of an object, the enableEvents() method is utilized...
The OS based file system services such as creating folders, files, verifying the permissions, changing file names etc...