Tuesday

J2EE Interview Questions And Answers

What is J2EE?
J2EE is 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 multitier, web-based applications.

What is the J2EE module?
A J2EE module consists of one or more J2EE components for the same
container type and one component deployment descriptor of that type.

What are the components of J2EE application?
A J2EE component is a self-contained functional software unit that is
assembled into a J2EE application with its related classes and files
and communicates with other components. The J2EE specification defines
the following J2EE components:
Application clients and applets are client components.
Java Servlet and JavaServer PagesTM (JSPTM) technology components
are web components.
Enterprise JavaBeansTM (EJBTM) components (enterprise beans) are
business components.
Resource adapter components provided by EIS and tool vendors.

What are the four types of J2EE modules?
1. Application client module
2. Web module
3. Enterprise JavaBeans module
4. Resource adapter module

What does application client module contain?
The application client module contains:
--class files,
--an application client deployment descriptor.
Application client modules are packaged as JAR files with a .jar extension.

What does web module contain?
The web module contains:
--JSP files,
--class files for servlets,
--GIF and HTML files, and
--a Web deployment descriptor.
Web modules are packaged as JAR files with a .war (Web ARchive) extension.

What are the differences between Ear, Jar and War files? Under what
circumstances should we use each one?
There are no structural differences between the files; they are all
archived using zip-jar compression. However, they are intended for
different purposes.
--Jar files (files with a .jar extension) are intended to hold generic
libraries of Java classes, resources, auxiliary files, etc.
--War files (files with a .war extension) are intended to contain
complete Web applications. In this context, a Web application is
defined as a single group of files, classes, resources, .jar files
that can be packaged and accessed as one servlet context.
--Ear files (files with a .ear extension) are intended to contain
complete enterprise applications. In this context, an enterprise
application is defined as a collection of .jar files, resources,
classes, and multiple Web applications.
Each type of file (.jar, .war, .ear) is processed uniquely by
application servers, servlet containers, EJB containers, etc.

What is the difference between Session bean and Entity bean ?
The Session bean and Entity bean are two main parts of EJB container.
Session Bean
--represents a workflow on behalf of a client
--one-to-one logical mapping to a client.
--created and destroyed by a client
--not permanent objects
--lives its EJB container(generally) does not survive system shut down
--two types: stateless and stateful beans
Entity Bean
--represents persistent data and behavior of this data
--can be shared among multiple clients
--persists across multiple invocations
--findable permanent objects
--outlives its EJB container, survives system shutdown
--two types: container managed persistence(CMP) and bean managed
persistence(BMP)

What is "applet" ?
A J2EE component that typically executes in a Web browser but can
execute in a variety of other applications or devices that support the
applet programming model.

What is "applet container" ?
A container that includes support for the applet programming model.

What is "application assembler" ?
A person who combines J2EE components and modules into deployable
application units.

Saturday

JavaScript Interview Questions And Answers

What is JavaScript?
A1: JavaScript is a general-purpose programming language designed to
let programmers of all skill levels control the behavior of software
objects. The language is used most widely today in Web browsers whose
software objects tend to represent a variety of HTML elements in a
document and the document itself. But the language can be--and
is--used with other kinds of objects in other environments. For
example, Adobe Acrobat Forms uses JavaScript as its underlying
scripting language to glue together objects that are unique to the
forms generated by Adobe Acrobat. Therefore, it is important to
distinguish JavaScript, the language, from the objects it can
communicate with in any particular environment. When used for Web
documents, the scripts go directly inside the HTML documents and are
downloaded to the browser with the rest of the HTML tags and content.

A2:JavaScript is a platform-independent,event-driven, interpreted
client-side scripting and programming language developed by Netscape
Communications Corp. and Sun Microsystems.

How is JavaScript different from Java?
JavaScript was developed by Brendan Eich of Netscape; Java was
developed at Sun Microsystems. While the two languages share some
common syntax, they were developed independently of each other and for
different audiences. Java is a full-fledged programming language
tailored for network computing; it includes hundreds of its own
objects, including objects for creating user interfaces that appear in
Java applets (in Web browsers) or standalone Java applications. In
contrast, JavaScript relies on whatever environment it's operating in
for the user interface, such as a Web document's form elements.
JavaScript was initially called LiveScript at Netscape while it was
under development. A licensing deal between Netscape and Sun at the
last minute let Netscape plug the "Java" name into the name of its
scripting language. Programmers use entirely different tools for Java
and JavaScript. It is also not uncommon for a programmer of one
language to be ignorant of the other. The two languages don't rely on
each other and are intended for different purposes. In some ways, the
"Java" name on JavaScript has confused the world's understanding of
the differences between the two. On the other hand, JavaScript is much
easier to learn than Java and can offer a gentle introduction for
newcomers who want to graduate to Java and the kinds of applications
you can develop with it.

What's relationship between JavaScript and ECMAScript?
ECMAScript is yet another name for JavaScript (other names include
LiveScript). The current JavaScript that you see supported in browsers
is ECMAScript revision 3.

How do you submit a form using Javascript?
Use document.forms[0].submit();
(0 refers to the index of the form – if you have more than one form in
a page, then the first one has the index 0, second has index 1 and so
on).

How do we get JavaScript onto a web page?
You can use several different methods of placing javascript in you pages.
You can directly add a script element inside the body of page.
1. For example, to add the "last updated line" to your pages, In your
page text, add the following:
<p>blah, blah, blah, blah, blah.</p>
<script type="text/javascript" >
<!-- Hiding from old browsers
document.write("Last Updated:" +
document.lastModified);
document.close();
// -->
</script>
<p>yada, yada, yada.</p>
(Note: the first comment, "<--" hides the content of the script from
browsers that don't understand javascript. The "// -->" finishes the
comment. The "//" tells javascript that this is a comment so
javascript doesn't try to interpret the "-->". If your audience has
much older browsers, you should put this comments inside your
javascript. If most of your audience has newer browsers, the comments
can be omitted. For brevity, in most examples here the comments are
not shown. )
The above code will look like this on Javascript enabled browsers,
2. Javascript can be placed inside the <head> element
Functions and global variables typically reside inside the <head> element.
<head>
<title>Default Test Page</title>
<script language="JavaScript" type="text/javascript">
var myVar = "";
function timer(){setTimeout('restart()',10);}
document.onload=timer();
</script>
</head>

Javascript can be referenced from a separate file
Javascript may also a placed in a separate file on the server and
referenced from an HTML page. (Don't use the shorthand ending "<script
... />). These are typically placed in the <head> element.
<script type="text/javascript" SRC="myStuff.js"></script>

How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with
client-side javascript. However , this can be done by coding a Java
applet that reads files for the script.

How to detect the operating system on the client machine?
In order to detect the operating system on the client machine, the
navigator.appVersion
string (property) should be used.

How can JavaScript make a Web site easier to use? That is, are there
certain JavaScript techniques that make it easier for people to use a
Web site?
JavaScript's greatest potential gift to a Web site is that scripts can
make the page more immediately interactive, that is, interactive
without having to submit every little thing to the server for a server
program to re-render the page and send it back to the client. For
example, consider a top-level navigation panel that has, say, six
primary image map links into subsections of the Web site. With only a
little bit of scripting, each map area can be instructed to pop up a
more detailed list of links to the contents within a subsection
whenever the user rolls the cursor atop a map area. With the help of
that popup list of links, the user with a scriptable browser can
bypass one intermediate menu page. The user without a scriptable
browser (or who has disabled JavaScript) will have to drill down
through a more traditional and time-consuming path to the desired
content.