61.Explain the Java Servlets. Explain its lifecycle.?
A servlet is a java class that provides a powerful mechanism for developing server
side application programs. It provides the component-based, platform-independent
methods for building any web based applications by overcoming the performance
limitations of CGI programs. A servlet application can run on any servlet enabled web
container. It runs completely in a JVM. Browser compatibility is not an issue as the
servlet run at the server side. The set of HTML-based calls can also be accessed by the
servlets. For interactive web applications, servlets is the right choice.
Servlet life cycle:
The servlet life cycle includes four stages:
- Loading and Instantiation : The servlet container loads the servlet during and
startup of a web application and or when the first request is made. The container
creates the servlet instances after loading the servlet .
- Initialization: Soon after the creation of the instance of a servlet, the container
invokes the init() method and passes the servelt’s the initialization information to the
init() method. The init() must be called by the servelt container before performing any
requests by the servlet.
- Responding for the requests: Once the initialization is properly done, the
servlet is ready to service the requests. The servlet creates separate threads for each
and every request. The servlet container invokes the service() method which in turn
invokes the appropriate doGet() or doPost() methods for handling the requests and
sending responses to the client using response objects.
- Destroying the servlet: If the servlet is not needed for processing the requests,
the destroy() method will be invoked by the container. This method also invoked only
once through out the life cycle of a servlet. Invoking the destroy() method indicates the
servlet container not to send any requests for the service and the servlet will release the
resources that are associated with it. JVM will claim the memory with the resources for
garbage collections.
62.Explain JSP. Describe JSP lifecycle.?
Java Server Pages (JSP): A JSP is used for the development of dynamic web pages.
JSP provides the server side scripting support for creating web applications that uses
database. JSP encourages the developers to directly insert the java code into .jsp file.
This process is very simple to develop and maintain.
JSP are loaded into the web servers’ memory as soon as receiving the request in the
very first time. The subsequent calls are served within a very short span of time. The
usage of JSP in combination with JDBC is very easy to efficient to develop the database
specific applications. JSP are platform independence as java is and any JSPage can be
ported to any platform.
JSP Life Cycle:
JSP services the requests from clients as that of a servlet. At the time of the JSP
request mapping, the request is handled by a special servlet. This servlet first checks
whether the first JSP servlet is older than the JSP. If it is so, the translation of JSP into
servlet class and compilation of this class is done. And then the request is handled by
the servlet like an ordinary servlet.
63.Explain the following java graphical interface framework.
Abstract windows toolkit (AWT)
Swing
Standard widget toolkit (SWT)
Abstract Windows Toolkit (AWT):
AWT provides the interface between the user and different windowing toolkits, such as
buttons, checkboxes, radio buttons and menus etc. AWT establishes the connection
between java applications and the Graphical User Interface. It is adequate to develop
many applications. For example, the menus on the TV sets and other remote controls
were developed using AWT (may be with Swings). AWT uses the basic GUI operating
systems controls. AWT is a part of Java Foundation Classes(JFC).
Swing:
A Swing toolkit includes much more rich set of GUI tools compared to AWT. Few more
high-level component sets are available in Swing such as (tree view, list boxes, tabbed
panes, pop up windows, tooltips, icons). To leverage cross-platform capabilities, Swing
supports more similar look and feel of the components. Swing is more flexible the all
swing components are light weight, thereby reduces the loading time.
Standard Widget Toolkit (SWT):
SWT is an open source widget tool kit for developing rich, efficient and portable GUI
applications. It was originally developed by IBM and being maintained by Eclipse
Foundation along with Eclipse IDE. It is an alternative to AWT and Swing. To display the
elements, it implements the operating system GUI libraries by using Java Native
Interface. The SWT applications are portable and unique for each platform.
The need of SWT is to provide a common API for accessing different operating system /
platform specific widgets. The goal for designing of SWT is high performance, native OS
look and feel, and platform integration. Swing on the other hand, designed to allow for a
highly customizable look and feel that is common across different platforms.
List out components by AWT? Explain each in brief.
- Button
- Canvas
- Choice
- Checkbox
- Container
-Panel
-Scrollpane
-Windows
- Label
- List
- Scrollbar
- TextComponent
-TextArea
-TextField
Button: A component that is used to display the command button on the canvas. By
clicking on the button, an action is performed
Canvas: A blank rectangular area on the screen on which an application can draw other
components or on which an action can be trapped.
Choice: A component that pop ups a menu of choices and the current choice is
displayed as the title of the menu.
Checkbox: A component that represents a check box that represents either true or false
state. If the option is true, then a tick mark appears in the box.
Container: A component that can contain another set of components. All these
components are tracked in a list.
- Panel: It is one of the simplest container classes. A panel provides space to
place other components including other panels.
- Scrollpane: A container which implements the scrolling that can be horizontal
or vertical for a child component.
- Windows: Represents a top level window that has no borders and no
menubar. A window must have a frame, a dialog box or another window as its owner
window.
Label: A component to place text in a container that is displayed as read only text
containing a single line
List: A component that specifies a list of items of text with a provision for the user to
select a single or multiple items.
Scrollbar: A component that is used basically for moving the visible area, where the
components / contents are not enough to appear in a single screen page.
Text Components:
- TextArea: A component where multiple lines of text can be typed / visible. It
can make to appear as read-only area or to appear for editing.
- TextField: A component where a single line of text can be typed / visible.
64.Tell us about yourself.?
Told about me...
65.What are your responsibilities as an Java Architect?
As an architect,i had to involve myself from project initiation till delivery and initial
support. Some of the responsibilities are:
* Technical inputs during business analysis.
* Coming up with use cases and validating the same with business analysts and end
users.
* Identifying the technology that will be used in the project .
* Recommending the development methodologies and frameworks.
* Defining the architecture and the infrastructure requirements.
* Providing the high level design and helping the designers in low level design.
* Defining and enforcing the coding standards.
* Conducting design audit.
* Guiding developers to accomplish difficult tasks.
* Helping to recruit technical people.
* Defining and achieving performance targets.
* Helping the project manager in planning and execution.
66.What are the different types of project development methodologies that are
available? Which one do you prefer or which one do you consider the best? Waterfall model, Iterative model like the XP and RUP are widely used ones. For
big projects, Waterfall model is mostly used. And of-late XP is also widely used.
But in practice, all of them are tailored to suit the requirements of the project and
are used exactly as specified.
And which one do you prefer?
Explain with adaptations.
67.What is an use case?
An use-case is actually a requirement from the user of the system. An use-case is a
statement of what the system will do at the request by one of the actors of the system.
68.What do you mean by an actor?
An actor could be an end user or an external system who is serviced by the system.
69.What are all the things you will consider when your application is required to
communicate to an external system.?
There could be many factors but primarily i will consider and finalise communication
mechanism, data exchange format, error handling and the initiating events.
70.What are exactly meaning by communication mechanism?
By communication mechanism, i mean synchronous or asynchronous
communication. If the application requires immediate response, i will use synchronous
communication methods or else asynchronous communication methods.
71.Can you give examples synchronous communication methods? And which
one do you prefer?
Sockets,HTTP,RMI,EJB,CORBA and web-services are all ways for synchronous
communication. I would prefer web-services.
72.Why web-services?
Web-services are based on service oriented architecture. They are platform
independent. Web-services make the application highly loose coupled - for example a
J2EE application can communicate with a .NET application with little effort and without
any great hiccups.
73.What data exchange formats do you prefer for inter-application
communication?
XML is the preferred choice because of its simplicity and self-descriptive syntax. But
sometimes you might really need an XML.
74.Can you explain under what circumstances you avoided using XML for data
exchange?
I worked on a banking application which had a suite of in-built applications which
were built on the J2EE architecture platform. And we had general wrapper value objects
which could be used across applications. There it did not make sense to convert the
value object to XML just for the sake of using XML.
75.When you pass Java value objects across applications, will it not lead to tight
coupling of the applications?
As I told you earlier, these 7 applications were built using the same J2EE
architecture, hence these inter-application data transfer objects were grouped as part of
the architectural common components.
76.Have you ever used any mechanism other than JMS for asynchronous
messaging?
No. I havent come across any other J2EE framework for asynchronous
communication. Moreover JMS is simple and highly stable for asynchronous
communication.
77.You have variety of options for persistence in J2EE. Which one do you prefer?
As you said, We have JDBC, Bean managed entity beans, container managed entity
beans, hibernate, JDO, toplink, etc. Some are specifications from sun and others are
open source frameworks. Each have their pros and cons. My first choice would be
hibernate, if i had to tweak for performance and require control - i would go with JDBC.
78.Why are you entirely avoiding entity beans?
First of all, entity beans havent evolved at the speed of market requirements. Its too
heavy for database operations. Even with BMPs you dont really get the control you
wanted. Entity beans are highly unsuitable for batch operations. And it also has a steep
learning curve for junior developers. I have seen many architects who have stayed clear
of entity beans for these obvious reasons.
79.Will you prefer writing common components on your own for the application
or will you prefer open-sourced components?
It depends on the project timelines, availability and quality of open-source
components and the real value add.
80.What is a value object?
Value object is a set of related data grouped together for purpose of communicating
within the application. Value objects are simple objects with setter and getter methods
and without any processing logic. They should be serializable because of their network
transfer capability.
|