Java Interview Questions and Answers
Here you can find Java Interview Questions and Answers.
Why Java Interview Questions and Answers Required?
In this Java Interview Questions and Answers section you can learn and practice Java Interview Questions and Answers to improve your skills in order to face technical
inerview by IT companies. By Practicing these interview questions, you can easily crack any Java interview.
Where can I get Java Interview Questions and Answers?
AllIndiaExams provides you lots Java Interview Questions and Answers with proper explanation. Fully solved examples with detailed answer description. All students,
freshers can download Java Interview Questions and Answers as PDF files and eBooks.
How to solve these Java Interview Questions and Answers?
You no need to worry, we have given lots of Java Interview Questions and Answers and also we have provided lots of FAQ's to quickly answer the questions in the Java
technical interview.
STRUTS Interview Questions and Answers
What is MVC?
Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic and data.
Model: The model contains the core of the application's functionality. The model enca psulates the state of the application. Sometimes the only functionality it contains is state. It
knows nothing about the view or controller.
View: The view provides the presentation of the model. It is the look of the application. The view can access the model getters, but it has no knowledge of the setters. In addition,
it knows nothing about the controller. The view should be notified when changes to the model occur.
Controller: The controller reacts to the user input. It creates and sets the model.
STRUTS Interview Questions and Answers
What is a framework?
Framework is made up of the set of classes which allow us to use a library in a best possible way for a specific requirement.
STRUTS Interview Questions and Answers
What is Struts framework?
* Struts framework is an open-source framework for developing the web applications in Java EE, based on MVC-2 architecture.
* It uses and extends the Java Servlet API.
* Struts is robust architecture and can be used for the development of application of any size.
* Struts framework makes it much easier to design scalable, reliable Web applications with Java.
* Struts provides its own Controller component and integrates with other technologies to provide the Model and the View.
* For the Model, Struts can interact with standard data access technologies, like JDBC and EJB, as well as most any third-party packages, like Hibernate, iBATIS, or Object
Relational Bridge. For the View, Struts works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems.
STRUTS Interview Questions and Answers
What is Jakarta Struts Framework?
Jakarta Struts is open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications.
Jakarta Struts is robust architecture and can be used for the development of application of any size.
Struts framework makes it much easier to design scalable, reliable Web applications with Java.
STRUTS Interview Questions and Answers
What is ActionServlet?
* The class org.apache.struts.action.ActionServlet is the called the ActionServlet.
* In the the Jakarta Struts Framework this class plays the role of controller.
* All the requests to the server goes through the controller.
* Controller is responsible for handling all the requests.
STRUTS Interview Questions and Answers
What is role of ActionServlet?
ActionServlet performs the role of Controller:
Process user requests
Determine what the user is trying to achieve according to the request
Pull data from the model (if necessary) to be given to the appropriate view,
Select the proper view to respond to the user
Delegates most of this grunt work to Action classes
Is responsible for initialization and clean-up of resources
STRUTS Interview Questions and Answers
What is Action Class?
Any java class which extends from org.apache.struts.action.Action is called Action class.
The Action is part of the controller.
The purpose of Action Class is to translate the HttpServletRequest to the business logic.
To use the Action, we need to Subclass and overwrite the execute() method.
The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method.
There should be no database interactions in the action.
The action should receive the request, call business objects (which then handle database, or interface with J2EE, etc) and then determine where to go next.
Even better, the business objects could be handed to the action at runtime (IoC style) thus removing any dependencies on the model.
The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward
object.
STRUTS Interview Questions and Answers
Write code of any Action Class?
package com.durgasoft;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class TestAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,HttpServletResponse response) throws Exception
{
return mapping.findForward("success");
}
}
STRUTS Interview Questions and Answers
What is ActionForm?
Any java class which extends from org.apache.struts.action.ActionForm is called ActionForm.
An ActionForm is also called JavaBean.
ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client
side.
STRUTS Interview Questions and Answers
What is Struts Validator Framework?
Struts Framework provides the functionality to validate the form data.
It can be use to validate the data on the users browser as well as on the server side.
Struts Framework emits the java scripts and it can be used validate the form data on the client browser.
Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class.
The Validator framework was developed by David Winterfeldt as third-party add-on to Struts.
Now the Validator framework is a part of Jakarta Commons project and it can be used with or without Struts.
The Validator framework comes integrated with the Struts Framework and can be used without doing any extra settings.