Main Content RSS FeedRecent Articles

J2EE Interview Questions »

Q)  What is J2EE

Rep) Java 2 Platform, Enterprise Edition.

Q)   What is J2EE application

Rep) Any deployable unit of J2EE functionality. This can be
a single J2EE module or a group of modules packaged
into an EAR file along with a J2EE application
deployment descriptor. J2EE applications are typically
engineered to be distributed across multiple computing
tiers.

Q)  What is J2EE component

Rep) A self-contained functional software unit supported by
a container and configurable at deployment time. The
J2EE specification defines the following J2EE
components: Application clients and applets are
components that run on the client. Java servlet and
JavaServer Pages (JSP) technology components are Web
components that run on the server. Enterprise
JavaBeans (EJB) components (enterprise beans) are
business components that run on the server. J2EE
components are written in the Java programming
language and are compiled in the same way as any
program in the language. The difference between J2EE
components and “standard” Java classes is that J2EE
components are assembled into a J2EE application,
verified to be well formed and in compliance with the
J2EE specification, and deployed to production, where
they are run and managed by the J2EE server or client
container.

Q)  What is J2EE module

Rep) A software unit that consists of one or more J2EE
components of the same container type and one
deployment descriptor of that type. There are four
types of modules: EJB, Web, application client, and
resource adapter. Modules can be deployed as
stand-alone units or can be assembled into a J2EE
application.

Q)  What is J2EE product

Rep) An implementation that conforms to the J2EE platform
specification.

Q)   What is J2EE product provider

Rep) A vendor that supplies a J2EE product.

Q)  What is J2EE server

Rep) The runtime portion of a J2EE product. A J2EE server
provides EJB or Web containers or both.

Q)   What is J2ME

Rep) Abbreviate of Java 2 Platform, Micro Edition.

Q)  What is J2SE

Rep) Abbreviate of Java 2 Platform, Standard Edition.

Q)  What is JAR

Rep) Java archive. A platform-independent file format that
permits many files to be aggregated into one file.

Q)   What is Java 2 Platform, Enterprise Edition(J2EE)

Rep) An environment for developing and deploying enterprise
applications. The J2EE platform consists of a set of
services, application programming interfaces (APIs),
and protocols that provide the functionality for
developing multitiered, Web-based applications.

Q)  What is Java 2 Platform, Micro Edition (J2ME)

Rep) A highly optimized Java runtime environment targeting
a wide range of consumer products, including pagers,
cellular phones, screen phones, digital set-top boxes,
and car navigation systems.

Q)  What is Java 2 Platform, Standard Edition (J2SE)

Rep) The core Java technology platform.

Q)  What is Java API for XML Processing (JAXP)

Rep) An API for processing XML documents. JAXP leverages
the parser standards SAX and DOM so that you can
choose to parse your data as a stream of events or to
build a tree-structured representation of it. JAXP
supports the XSLT standard, giving you control over
the presentation of the data and enabling you to
convert the data to other XML documents or to other
formats, such as HTML. JAXP provides namespace
support, allowing you to work with schema that might
otherwise have naming conflicts.

Q)  What is Java API for XML Registries (JAXR)

Rep) An API for accessing various kinds of XML registries.

Q)  What is Java API for XML-based RPC (JAX-RPC)

Rep) An API for building Web services and clients that use
remote procedure calls and XML

Q)   What is Java IDL

Rep) A technology that provides CORBA interoperability and
connectivity capabilities for the J2EE platform. These
capabilities enable J2EE applications to invoke
operations on remote network services using the Object
Management Group IDL and IIOP.

Q)  What is Java Message Service (JMS)

Rep) An API for invoking operations on enterprise messaging
systems.

Q)  What is Java Naming and Directory Interface (JNDI)

Rep) An API that provides naming and directory
functionality.

Q)   What is Java Secure Socket Extension (JSSE)

Rep) A set of packages that enable secure Internet
communications.

Q)   What is Java Transaction API (JTA)

Rep) An API that allows applications and J2EE servers to
access transactions.

Q)  What is Java Transaction Service (JTS)

Rep) Specifies the implementation of a transaction manager
that supports JTA and implements the Java mapping of
the Object Management Group Object Transaction Service
1.1 specification at the level below the API.

Q)  What is JavaBeans component

Rep) A Java class that can be manipulated by tools and
composed into applications. A JavaBeans component must
adhere to certain property and event interface
conventions.

Q)  What is JavaMail

Rep) An API for sending and receiving email.

Q)   What is JavaServer Faces Technology

Rep) A framework for building server-side user interfaces
for Web applications written in the Java programming
language.

Q)  What is JavaServer Faces conversion model

Rep) A mechanism for converting between string-based markup
generated by JavaServer Faces UI components and
server-side Java objects.

Q)  What is JavaServer Faces event and listener model

Rep) A mechanism for determining how events emitted by
JavaServer Faces UI components are handled. This model
is based on the JavaBeans component event and listener
model.

Q)  What is JavaServer Faces _expression language

Rep) A simple _expression language used by a JavaServer
Faces UI component tag attributes to bind the
associated component to a bean property or to bind the
associated component’s value to a method or an
external data source, such as a bean property. Unlike
JSP EL expressions, JavaServer Faces EL expressions
are evaluated by the JavaServer Faces implementation
rather than by the Web container.

Q)  What is JavaServer Faces navigation model

Rep) A mechanism for defining the sequence in which pages
in a JavaServer Faces application are displayed.

Q)  What is JavaServer Faces UI component

Rep) A user interface control that outputs data to a client
or allows a user to input data to a JavaServer Faces
application.

Q)  What is JavaServer Faces UI component class

Rep) A JavaServer Faces class that defines the behavior and
properties of a JavaServer Faces UI component.

Q)  What is JavaServer Faces validation model

Rep) A mechanism for validating the data a user inputs to a
JavaServer Faces UI component.

Q)  What is JavaServer Pages (JSP)

Rep) An extensible Web technology that uses static data,
JSP elements, and server-side Java objects to generate
dynamic content for a client. Typically the static
data is HTML or XML elements, and in many cases the
client is a Web browser.

Q)  What is JavaServer Pages Standard Tag Library(JSTL)

Rep) A tag library that encapsulates core functionality
common to many JSP applications. JSTL has support for
common, structural tasks such as iteration and
conditionals, tags for manipulating XML documents,
internationalization and locale-specific formatting
tags, SQL tags, and functions.

Q)  What is JAXR client

Rep) A client program that uses the JAXR API to access a
business registry via a JAXR provider.

OVERVIEW OF SERVLETS »

OVERVIEW OF SERVLETS

Servlets provide a Java based solution used to address the problems currently associated with doing server side programming including inextensible scripting solution, platform specific API’s, and incomplete interfaces.

Servlets are objects that confirm to a specific interface that can be plugged into a Java based server. Servlets are to the server side what applets are to the client side object byte code that can be dynamically loaded off the net.
They differ from applets. In that they are face less objects (with out graphics or GUI component).They serve as platform independent, dynamically loadable, pluggable  helper byte code objects on the server side that can be used to dynamically extend server side functionality.

For example, an HTTP servlet can be used to generate dynamic HTML content. When you use servlets to do dynamic content you get the following advantages:

They are faster and cleaner than CGI scripts
They use a  standard API (the servlet API)
They provide all the advantages of Java(run on variety of    servers with out needing to be rewritten)

The Attractiveness of Servlets

There are many features of servlets that make them easy and attractive to use. These include:
Easily configured using the GUI based admin Tool.
Can be loaded and invoked from a local disc or remotely across the network.
Can be linked together, or chained so that on a servlet can call another servlet, or several servlets in sequence.
Can be called dynamically from within HTML pages, using server side include tags.
Are secure- even when downloading across the net work, the servlet security model and servlet sandbox protect your system from unfriendly behavior.

The Advantages of the servlet API

One of the great advantages of the servlet API is protocol independence. It assumes nothing about:
The protocol being used to transmit on the net
How it is loaded
The server environment it will be running in tjese qualities are important, because it allows the servlet API to be embedded in many different kindsof servers.
There are other advantages to the servlet API  as well.
These include:
It’s extensible-you can inherit all your functionality from the classes made available to you;
It’s simple, small, and easy to use.

JAVA SERVLET FEATURES:

The JavaServer provides several important servlet features.
These includes:
Loading and Invoking Servlets

Servlets can be loaded both locally and remotely.

Filters and Servlet Chaining

The JavaServer uses mime types to call servlets sequentially.

Server-Side Includes

Server can be invoked from dynamic HTML docements using    server-side include tags.

Replacing CGI Scripts

Servlets are an effective substitute for CGI scripts, and provide a faster and cleaner way to genarate dynamic documents.

INTERNAL SERVLETS:

The Java TM Web Server TM servlet architecture is very flexible and the server takes advantage of thie by dividing  its work among several internal servlets. These are:

File Servlet:

The File Servlet provides the standard document serving capabilities of Java Web Server. This servlet includes a caching mechanism to speed up response times for frequently accessed files.

Invoker Servlet:

The purpose of this servlet is to invoke other servlets which are explicitly requested by name, that is

http://<server-host-name>/servlets/servlet name.

Server Side Include Servlet:

Servlets can be embedded within html documents using the servlet tag. When the server detects the servlet, and sends output of the servlet to the client at the point where the servlet tag was embedded.

Admin Servlet:

The Admin servlet facilitates administration of the Java web server through a GUI front end Administration Tool.

CGI Servlet:

This servlet acts as a gateway for CGI 1.1 interface. This servlet allows any program that utilizes the CGI 1.1     standard to under operate Java Web Server.

Image Map Servlet:

This servlet implements server-side image maps utilizing an extension of standard NCSA map files.

Exception Handling and their uses »

Q)  What is the difference between ‘throw’ and ‘throws’ ?And it’s application?

Rep) Exceptions that are thrown by java runtime systems can be handled by Try and catch blocks. With throw exception we can handle the exceptions thrown by the program itself. If a method is capable of causing an exception that it does not
handle, it must specify this behavior so the callers of the method can guard
against that exception.

Q)   What is the difference between ‘Exception’ and ‘error’ in java?

Rep) Exception and Error are the subclasses of the Throwable class. Exception class is used for exceptional conditions that user program should catch. With exception class we can subclass to create our own custom exception.
Error defines exceptions that are not excepted to be caught by you program. Example is Stack Overflow.

Q)  What is ‘Resource leak’?

Rep) Freeing up other resources that might have been allocated at the beginning of a method.

Q)  What is the ‘finally’ block?

Rep) Finally block will execute whether or not an exception is thrown. If an exception is thrown, the finally block will execute even if no catch statement match the exception. Any time a method is about to return to the caller from inside try/catch block, via an uncaught exception or an explicit return statement, the finally clause is also execute.

Q)  Can we have catch block with out try block? If so when?

Rep) No. Try/Catch or Try/finally form a unit.

Q)  What will happen to the Exception object after exception handling?

Rep) It will go for Garbage Collector. And frees the memory.

Q)  How many Exceptions we can define in ‘throws’ clause?

Rep) We can define multiple exceptions in throws clause.
Signature is.. : type method-name (parameter-list) throws exception-list

Q)  The finally block is executed when an exception is thrown, even if no catch matches it.
True/False

Rep) True

Q)   The subclass exception should precede the base class exception when used within the catch clause.
True/False

Rep) True

Q)   Exceptions can be caught or rethrown to a calling method.
True/False

Rep) True

Q)  The statements following the throw keyword in a program are not executed.
True/False

Rep) True

Q)  The toString ( ) method in the user-defined exception class is overridden.
True/False

Rep) True

How to get a Leap Year »

import java.util.Calendar.*;

import java.lang.*;  //its’ a default package which will import

class LeapYear {

public static void main(String args[])throws Exception {

Calendar cal=Calendar.getInstance();

int year=cal.get(Calendar.YEAR);

if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))

{   System.out.println(”Leap Year”);          }else  {

System.out.println(”Not a Leap Year);      }

}

}  // The Meaning of above is every 4 year’s the LeapYear comes and when The Centuries comes into pictures it will divided by the 400 so that the remainder should be zera is the Leap year