· 7 years ago · Feb 15, 2019, 12:54 PM
11) What is J2EE?
2
3J2EE means Java 2 Enterprise Edition. The functionality of J2EE is developing multitier web-based applications. The J2EE platform is consists of a set of services, application programming interfaces (APIs), and protocols.
4
52) What are the four components of the J2EE application?
6
7Application clients components.
8Servlet and JSP technology are web components.
9Business components (JavaBeans).
10Resource adapter components
113) What are the types of J2EE clients?
12
13Applets
14Application clients
15Java Web Start-enabled clients, by Java Web Start technology.
16Wireless clients, based on MIDP technology.
174) What is considered as a web component?Â
18
19Java Servlet and Java Server Pages technology components are web components. Servlets are Java programming language that dynamically receives requests and makes responses. JSP pages execute as servlets but allow a more natural approach to creating static content.
20
215) What is JSF?
22
23JavaServer Faces (JSF) is a user interface (UI) designing framework for Java web applications. JSF provides a set of reusable UI components, a standard for web applications. JSF is based on MVC design pattern. It automatically saves the form data to the server and populates the form date when display on the client side.
24
256) Define Hash table
26
27HashTable is just like Hash Map, Collection having a key(Unique), value pairs. Hashtable is a collection Synchronized object. It does not allow duplicate values or null values.
28
297) What is Hibernate?
30
31Hibernate is an open source object-relational mapping and query service. In hibernate we can write HQL instead of SQL which save developers to spend more time on writing the native SQL. Hibernate has a more powerful association, inheritance, polymorphism, composition, and collections. It is a beautiful approach for persisting into the database using the Java objects. Hibernate also allows you to express queries using Java-based criteria.
32
33
348 ) What is the limitation of hibernate?
35
36Â Slower in executing the queries than queries are used directly.
37Only query language support for composite keys.
38No shared references to value types.
399) What are the advantages of hibernate?
40
41Â Hibernate is portable i mean database independent, Vendor independence.
42Â Standard ORM also supports JPA
43Â Mapping of the Domain object to the relational database.
44Â Hibernate is better than plain JDBC.
45Â JPA provider in JPA based applications.
4610) What is ORM?
47
48ORM stands for Object-Relational mapping. The objects in a Java class which is mapped into the tables of a relational database using the metadata that describes the mapping between the objects and the database. It works by transforming the data from one representation to another.
49
5011) Difference between Save and Saveorupdate?
51
52Save() – This method in Hibernate is used to stores an object in the database. It inserts an entry if the record doesn’t exist, otherwise not.
53
54Saveorupdate ()Â -This method in the hibernate is used for updating the object using identifier. If the identifier is missing this method calls save(). If the identifier exists, it will call the update method.
55
5612) Difference between load and get method?
57
58load() can’t find the object from cache or database, an exception is thrown, and the load() method never returns null.
59
60get() method returns null if the object can’t be found. The load() method may return a proxy instead of a real persistent instance get() never returns a proxy.
61
6213) How to invoke a stored procedure in hibernate?
63
64{ ? = call thisISTheProcedure() }
65
6614) What are the benefits of ORM?
67
68Productivity
69Maintainability
70Performance
71Vendor independence
7215) What are the Core interfaces of Hibernate framework?
73
74Â Session Interface
75SessionFactory Interface
76Configuration Interface
77Transaction Interface
78Query and Criteria Interface
7916) What is the file extension used for hibernate mapping file?
80
81The name of the file should be like this: filename.hbm.xml
82
8317) What is the file name of hibernate configuration file?
84
85The name of the file should be like this: hibernate.cfg.xml
86
8718) How Hibernate is database independent explain?
88
89Only changing the full property full database can be replaced.
90
911
922
933
94<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property> and
95
96<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
97
9819) How to add Hibernate mapping file in hibernate configuration file?
99
100By <mapping resource=†filename.hbm.xmlâ€/>
101
10220) Define connection pooling?
103
104Connection pooling is a mechanism to reuse the connection which contains the number of already created object connection. So whenever it is necessary for an object, this mechanism is used to get objects without creating it.
105
10621) What is the Hibernate proxy?
107
108An object proxy is just a way to avoid retrieving an object until you need it. Hibernate 2 does not proxy objects by default.
109
11022) What do you create a SessionFactory?
111
1121
113Configuration cfg = new Configuration(); cfg.addResource("dir/hibernate.hbm.xml"); cfg.setProperties( System.getProperties() ); SessionFactory sessions = cfg.buildSessionFactory();
114
11523)Â What is HQL?
116
117HQL stands for Hibernate Query Language. Hibernate allows to the user to express queries in its portable SQL extension, and this is called as HQL. It also allows the user to express in native SQL.
118
11924) What are the Collection types in Hibernate?
120
121Set, List, Array, Map, Bag are collection type in Hibernate.
122
12325) What is a thin client?
124
125A thin client is a program interface to the application that does not have any operations like the query of databases, execute complex business rules, or connect to legacy applications.
126
12726) Differentiate between .ear, .jar and .war files.
128
129.jar files:Â These files are with the .jar extension. The .jar files contain the libraries, resources and accessories files like property files.
130
131.war files:Â These files are with the .war extension. The .war file contains JSP, HTML, javascript and other files necessary for the development of web applications.
132
133.ear files:Â The .ear file contains the EJB modules of the application.
134
13527) What is the JSP tag?
136
137In JSP tags can be divided into four different types.
138
139Directives
140Declarations
141Scriplets
142Expressions
14328) How to access web.xml init parameters from JSP page?
144
145For example, if you have:
146<context-param> <param-name>Id</param-name> <param-value>this is the value</param-value></context-param>
147You can access this parameter
148Id: <h:outputText value=â€#{initParam[‘Id’]}â€/>
149
15029) What are JSP Directives?
151
1521.page Directives <%@page language=â€java†%>
1532. include Directives: <%@ include file=â€/header.jsp†%>
1543. taglib Directives <%@ taglib uri=â€tlds/taglib.tld†prefix=â€html†%>
15530) What is the EAR file?
156
157An EAR file is a JAR file with a .ear extension. A J2EE application with all of its modules is delivered in an EAR file.
158
15931) What will happen when you compile and run the following code?
160
1611
162public class MyClass { public static void main(String argv[]){ int array[]=new int[]{1,2,3}; System.out.println(array [1]); } } Answer: Compiled and shows output : 2
163
16432) What are Struts?
165
166Struts framework is a Model-View-Controller(MVC) architecture for designing large-scale applications. It is a combination of Java Servlets, JSP, Custom tags, and message. Struts help you to create an extensible development environment for your application, based on published standards and proven design patterns. Model in many applications represents the internal state of the system as a set of one or more JavaBeans.The View is most often constructed using JavaServer Pages (JSP) technology. The Controller is focused on receiving requests from the client and producing the next phase of the user interface to an appropriate View component. The primary component of the Controller in the framework is a servlet of class ActionServlet. This servlet is configured by defining a set of ActionMappings.
167
16833. What is ActionErrors?
169
170ActionErrors object that encapsulates any validation errors that have been found. If no errors are found, return null or an ActionErrors object with no recorded error messages. The default implementation attempts to forward to the HTTP version of this method. Holding request parameters mapping and request  and returns a set of validation errors, if validation failed; an empty set or null
171
17234) What is ActionForm?
173
174ActionForm is a Java bean that associates one or more ActionMappings. A java bean become FormBean when extend org.apache.struts.action.ActionForm class. ActionForm object is automatically populated on the server side which data has been entered by the client from UI. ActionForm maintains the session state for a web application.
175
17635) What is action mapping??
177
178In action mapping, we specify action class for a particular URL ie path and different target view ie forwards on to which request response will be forwarded.
179
180The ActionMapping represents the information that the ActionServlet knows about the mapping of a particular request to an instance of a particular Action class. The mapping is passed to the execute() method of the Action class, enabling access to this information directly.
181
18236) What is the MVC on struts?
183
184MVCÂ stands Model-View-Controller.
185
186Model: Model in many applications represent the internal state of the system as a set of one or more JavaBeans.
187
188View: The View is most often constructed using JavaServer Pages (JSP) technology.
189
190Controller: The Controller is focused on receiving requests from the client and producing the next phase of the user interface to an appropriate View component. The primary component of the Controller in the framework is a servlet of class ActionServlet. This servlet is configured by defining a set of ActionMappings.
191
19237)Â What are the different modules in spring?
193
194There are seven core modules in spring
195
196The Core container module
197O/R mapping module (Object/Relational)
198DAO module
199Application context module
200Aspect Oriented Programming
201Web module
202MVC module
20338) What is Bean Factory, have you used the XMLBean factory?
204
2051
206XmlBeanFactory is one of the implementation of bean Factory org.springframework.beans.factory.xml.XmlBeanFactory is used to creat bean instance defined in our xml file. BeanFactory factory = new XmlBeanFactory(new FileInputStream("beans.xml")); Or ClassPathResource resorce = new ClassPathResource("beans.xml"); XmlBeanFactory factory = new XmlBeanFactory(resorce);
207
208
20939) What is Spring?
210
211Spring is a lightweight open source framework for the development of enterprise application that resolves the complexity of enterprise application development is also providing a cohesive framework for J2EE application development which is primarily based on IOC (inversion of control) or DI (dependency injection) design pattern.
212
21340) What is the functionality of ActionServlet and RequestProcessor?
214
215Receiving the HttpServletRequest
216Populating JavaBean from the request parameters
217Displaying response on the web page Issues
218Content type issues handling
219Provide extension points
22041) ActionServlet, RequestProcessor, and Action classes are the components of
221
222Controller
223
22442) What is default scope in Spring?
225
226Singleton.
227
22843) What are the advantages of Spring usage?
229
230Pojo based programming enables reuse component.
231Improve productivity and subsequently reduce development cost.
232Dependency Injection can be used to improve testability.
233Spring required enterprise services without a need for the expensive application server.
234It reduces coupling in code and improves maintainability.
23544)What are the Benefits Spring Framework?
236
237Lightweight container
238Spring can effectively organize your middle tier objects
239Initialization of properties is easy. No need to read from a properties file
240application code is much easier to unit test
241Objects are created Lazily, Singleton – configuration
242Spring’s configuration management services can be used in any architectural layer, in whatever runtime environment
24345) Lifecycle interfaces in spring?
244
245
2461
2471) InitializingBean <bean id="expInitBean" init-method="init"/> public class ExpBean { public void init() { // do some initialization code } } OR <bean id=" expInitBean "/> public class ExpBean implements InitializingBean { public void afterPropertiesSet() { // do some initialization code } } 2) DisposableBean <bean id="expInitBean" destroy-method="cleanup"/> public class ExpBean { public void cleanup() { // do some destruction code (like releasing pooled connections) } } OR <bean id="expInitBean"/> public class ExpBean implements DisposableBean { public void destroy() { // do some destruction code (like releasing pooled connections) } }
24846) How to Create Object without using the keyword “new†in java?
249
250Without new, the Factory methods are used to create objects for a class. For example
251Calender c=Calender.getInstance();
252Here Calender is a class, and the method getInstance() is a Factory method which can create an object for Calendar class.
253
25447) What is a servlet?
255
256Servlets is a server-side component that provides a powerful mechanism for developing server side programs. Servlets is a server, as well as platform-independent and Servlets, are designed for various protocols. Most commonly used HTTP protocols. Servlets use the classes in the java packages javax.servlet, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpSession;. All servlets must implement the Servlet interface, which defines life-cycle methods.
257
25848) Servlet is pure java object or not?
259
260Yes, pure java object.
261
26249)Â What are the phases of the servlet life cycle?
263
264The life cycle of a servlet consists of the following phases:
265
266Servlet class loading
267Servlet instantiation
268Â the init method
269Request handling (call the service method)
270Removal from service (call the destroy method)
27150) What must be implemented by all Servlets?
272The Servlet Interface must be implemented by all servlets