You are on page 1of 9

1) What is J2EE? J2EE means Java 2 Enterprise Edition. The functionality of J2EE is developing mu ltitier web-based applications .

The J2EE platform is consists of a set of servic es, application programming interfaces (APIs), and protocols. 2) What are the four components of J2EE application? Application clients components. Servlet and JSP technology are web components. Business components (JavaBeans). Resource adapter components 3) What are types of J2EE clients? Applets Application clients Java Web Start-enabled clients, by Java Web Start technology. Wireless clients, based on MIDP technology. 4) What are considered as a web component? Java Servlet and Java Server Pages technology components are web components. Ser vlets are Java programming language that dynamically receive requests and make r esponses. JSP pages execute as servlets but allow a more natural approach to cre ating static content. 5) What is JSF? JavaServer Faces (JSF) is a user interface (UI) designing framework for Java web applications. JSF provide a set of reusable UI components, standard for web app lications.JSF is based on MVC design pattern. It automatically saves the form da ta to server and populates the form date when display at client side. 6) Define Hash table HashTable is just like Hash Map,Collection having key(Unique),value pairs. Hasht able is a collection Synchronozed object .It does not allow duplicate values but it allows null values. 7) What is Hibernate? Hibernate is a open source object-relational mapping and query service. In hiber nate we can write HQL instead of SQL which save developers to spend more time on writing the native SQL. Hibernate has more powerful association, inheritance, p olymorphism, composition, and collections. It is a beautiful approach for persis ting into database using the java objects. Hibernate also allows you to express queries using java-based criteria . 8 ) What is the limitation of hibernate? Slower in executing the queries than queries are used directly. Only query language support for composite keys. No shared references to value types. 9) What are the advantage of hibernate. Hibernate is portable i mean database independent, Vendor independence. Standard ORM also supports JPA Mapping of Domain object to relational database. Hibernate is better then plain JDBC. JPA provider in JPA based applications. 10) What is ORM? ORM stands for Object-Relational mapping. The objects in a Java class which is m apped in to the tables of a relational database using the metadata that describe s the mapping between the objects and the database. It works by transforming the data from one representation to another.

11) Difference between save and saveorupdate save() This method in hibernate is used to stores an object into the database. I t insert an entry if the record doesn t exist, otherwise not. saveorupdate () -This method in the hibernate is used for updating the object us ing identifier. If the identifier is missing this method calls save(). If the id entifier exists, it will call update method. 12) Difference between load and get method? load() can t find the object from cache or database, an exception is thrown and th e load() method never returns null. get() method returns null if the object can t be found. The load() method may retu rn a proxy instead of a real persistent instance get() never returns a proxy. 13) How to invoke stored procedure in hibernate? { ? = call thisISTheProcedure() } 14) What are the benefits of ORM? Productivity Maintainability Performance Vendor independence 15) What the Core interfaces are of hibernate framework? Session Interface SessionFactory Interface Configuration Interface Transaction Interface Query and Criteria Interface 16) What is the file extension used for hibernate mapping file? The name of the file should be like this : filename.hbm.xml 17) What is the file name of hibernate configuration file? The name of the file should be like this : hibernate.cfg.xml 18) How hibernate is database independent explain? Only changing the property [xml] <property name= hibernate.dialect >org.hibernate.dialect.Oracle9Dialect</property> a nd <property name= hibernate.connection.driver_class >oracle.jdbc.driver.OracleDriver</ property> [/xml] full database can be replaced. 19) How to add hibernate mapping file in hibernate configuration file? By <mapping resource= filename.hbm.xml /> 20) Define connection pooling? Connection pooling is a mechanism reuse the connection.which contains the number of already created object connection. So whenever there is a necessary for obje ct, this mechanism is used to directly get objects without creating it. 21) What is the hibernate proxy? An object proxy is just a way to avoid retrieving an object until you need it. H ibernate 2 does not proxy objects by default. 22) What do you create a SessionFactory? [java] Configuration cfg = new Configuration();

cfg.addResource( dir/hibernate.hbm.xml ); cfg.setProperties( System.getProperties() ); SessionFactory sessions = cfg.buildSessionFactory(); [/java] 23) What is HQL? HQL stands for Hibernate Query Language. Hibernate allows to the user to express queries in its own portable SQL extension and this is called as HQL. It also al lows the user to express in native SQL. 24) What are the Collection types in Hibernate ? Set, List, Array, Map, Bag 25) What is a thin client? A thin client is a program interface to the application that does not have any o perations like query of databases, execute complex business rules, or connect to legacy applications. 26) Differentiate between .ear, .jar and .war files. .jar files: These files are with the .jar extenstion. The .jar files contains th e libraries, resources and accessories files like property files. .war files: These files are with the .war extension. The .war file contains jsp, html, javascript and other files for necessary for the development of web appli cations. .ear files: The .ear file contains the EJB modules of the application. 27) What are the JSP tag? In JSP tags can be divided into 4 different types. Directives Declarations Scriplets Expressions 28) How to access web.xml init parameters from jsp page? For example, if you have: <context-param> <param-name>Id</param-name> <param-value>this is the value</para m-value></context-param> You can access this parameter Id: <h:outputText value= #{initParam['Id']} /> 29) What are JSP Directives? Directives <%@page language= java %> 2. include Directives: <%@ include file= /header.jsp 3. taglib Directives <%@ taglib uri= tlds/taglib.tld

%> prefix= html %>

30) What is the EAR file? An EAR file is a JAR file with an .ear extension. A J2EE application with all of its modules is delivered in EAR file. 31) What will happen when you compile and run the following code? [java] public 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 [/java]

32) What is Struts? Struts framework is a Model-View-Controller(MVC) architecture for designing larg e scale applications. Which is combines of Java Servlets, JSP, Custom tags, and message. Struts helps you to create an extensible development environment for yo ur application, based on published standards and proven design patterns. Model i n many applications represent the internal state of the system as a set of one o r 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. 33.What is ActionErrors? ActionErrors 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 versi on of this method. Holding request parameters mapping and request and returns set of validation errors, if validation failed; an empty set or null 34) What is ActionForm? ActionForm is a Java bean that associates one or more ActionMappings. A java bea n become FormBean when extend org.apache.struts.action.ActionForm class. ActionF orm object is automatically populated on the server side which data has been ent ered by the client from UI. ActionForm maintains the session state for web appli cation. 35) What is action mapping?? In action mapping we specify action class for particular url ie path and diffren t target view ie forwards on to which request response will be forwarded.The Act ionMapping represents the information that the ActionServlet knows about the map ping of a particular request to an instance of a particular Action class.The map ping is passed to the execute() method of theAction class, enabling access to th is information directly. 36) What is the MVC on struts. MVC stands Model-View-Controller. Model: Model in many applications represent the internal state of the system as a set of one or more JavaBeans. View: The View is most often constructed using JavaServer Pages (JSP) technology . Controller: 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. 37) What are different modules in spring? There are seven core modules in spring The Core container module O/R mapping module (Object/Relational) DAO module Application context module Aspect Oriented Programming Web module MVC module 38) What is Bean Factory, have you used XMLBean factory? [java] XmlBeanFactory is one of the implementation of bean Factory org.springframework.beans.factory.xml.XmlBeanFactory is used to creat bean insta

nce 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); [/java] 39) What is Spring? Spring is a light weight open source framework for the development of enterpris e application that resolves the complexity of enterprise application development also providing a cohesive framework for J2EE application development. Which is primarily based on IOC (inversion of control) or DI (dependency injection) desig n pattern. 40) Functionality of ActionServlet and RequestProcessor? Receiving the HttpServletRequest Populating JavaBean from the request parameters Displaying response on the web page Issues Content type issues handling Provide extension points 41) ActionServlet, RequestProcessor and Action classes are the components of Controller 42) What is default scope in Spring? Singleton. 43) What are advantages of Spring usage? Pojo based programming enables reuse component. Improve productivity and subsequently reduce development cost. Dependency Injection can be used to improve testability. Spring required enterprise services without a need of expensive application serv er. It reduces coupling in code and improves maintainability. 44)What are the Benefits Spring Framework ? Light weight container Spring can effectively organize your middle tier objects Initialization of properties is easy ? no need to read from properties file application code is much easier to unit test Objects are created Lazily , Singleton configuration Spring s configuration management services can be used in any architectural layer, in whatever runtime environment 45) Lifecycle interfaces in spring ? [java] 1) 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 conne ctions) } } [/java] 46) How to Create Object without using the keyword new in java? Without new the Factory mehtods are used to create objects for a class. For exam ple Calender c=Calender.getInstance(); here Calender is a class and the method getInstance() is a Factory method which can create object for Calender class. 47) What is servlet? Servlets is a server side components that provide a powerful mechanism for devel oping server side programs. Servlets is a server as well as platform-independent and Servlets are designed for a various protocols. Most commonly used HTTP prot ocols. Servlets uses the classes in the java packages javax.servlet, javax.servl et.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servle t.http.HttpSession;. All servlets must implement the Servlet interface, which de fines life-cycle methods. 48) Servlet is pure java object or not? Yes, pure java object. 49) What are the phases of the servlet life cycle? The life cycle of a servlet consists of the following phases: Servlet class loading Servlet instantiation the init method Request handling (call the service method) Removal from service (call the destroy method) 50) What must be implemented by all Servlets? The Servlet Interface must be implemented by all servlets. What makes J2EE suitable for distributed multitiered Applications? - The J2EE platform uses a multitiered distributed application model. Applicatio n logic is divided into components according to function, and the various applic ation components that make up a J2EE application are installed on different mach ines depending on the tier in the multitiered J2EE environment to which the appl ication component belongs. The J2EE application parts are: Client-tier components run on the client machine. Web-tier components run on the J2EE server. Business-tier components run on the J2EE server. Enterprise information system (EIS)-tier software runs on the EIS server. What is J2EE? - J2EE is an environment for developing and deploying enterprise a pplications. The J2EE platform consists of a set of services, application progra mming interfaces (APIs), and protocols that provide the functionality for develo ping multitiered, web-based applications. What are - A J2EE d into a th other the components of J2EE application? component is a self-contained functional software unit that is assemble J2EE application with its related classes and files and communicates wi components. The J2EE specification defines the following J2EE component

s: Application clients and applets are client components. Java Servlet and JavaServer Pages technology components are web components. Enterprise JavaBeans components (enterprise beans) are business components. Resource adapter components provided by EIS and tool vendors. What do Enterprise JavaBeans components contain? - Enterprise JavaBeans componen ts contains Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. All the business code is contained inside an Enterprise Bean which receives dat a from client programs, processes it (if necessary), and sends it to the enterpr ise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client progr am. Is J2EE application only a web-based? - No, It depends on type of application th at client wants. A J2EE application can be web-based or non-web-based. if an app lication client executes on the client machine, it is a non-web-based J2EE appli cation. The J2EE application can provide a way for users to handle tasks such as J2EE system or application administration. It typically has a graphical user in terface created from Swing or AWT APIs, or a command-line interface. When user r equest, it can open an HTTP connection to establish communication with a servlet running in the web tier. Are JavaBeans J2EE components? - No. JavaBeans components are not considered J2E E components by the J2EE specification. They are written to manage the data flow between an application client or applet and components running on the J2EE serv er or between server components and a database. JavaBeans components written for the J2EE platform have instance variables and get and set methods for accessing the data in the instance variables. JavaBeans components used in this way are t ypically simple in design and implementation, but should conform to the naming a nd design conventions outlined in the JavaBeans component architecture. Is HTML page a web component? - No. Static HTML pages and applets are bundled wi th web components during application assembly, but are not considered web compon ents by the J2EE specification. Even the server-side utility classes are not con sidered web components, either. What can be considered as a web component? - J2EE Web components can be either s ervlets or JSP pages. Servlets are Java programming language classes that dynami cally process requests and construct responses. JSP pages are text-based documen ts that execute as servlets but allow a more natural approach to creating static content. What is the container? - Containers are the interface between a component and th e low-level platform specific functionality that supports the component. Before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE application and deployed into its container. What are container services? - A container is a runtime support of a system-leve l entity. Containers provide components with services such as lifecycle manageme nt, security, deployment, and threading. What is the web container? - Servlet and JSP containers are collectively d to as Web containers. It manages the execution of JSP page and servlet nts for J2EE applications. Web components and their container run on the rver. What is Enterprise JavaBeans (EJB) container? - It manages the execution rprise beans for J2EE applications. referre compone J2EE se of ente

Enterprise beans and their container run on the J2EE server. What is Applet container? - IManages the execution of applets. Consists of a Web browser and Java Plugin running on the client together. How do we package J2EE components? - J2EE components are packaged separately and bundled into a J2EE application for deployment. Each component, its related fil es such as GIF and HTML files or server-side utility classes, and a deployment d escriptor are assembled into a module and added to the J2EE application. A J2EE application is composed of one or more enterprise bean,Web, or application clien t component modules. The final enterprise solution can use one J2EE application or be made up of two or more J2EE applications, depending on design requirements . A J2EE application and each of its modules has its own deployment descriptor. A deployment descriptor is an XML document with an .xml extension that describes a component s deployment settings. What is a thin client? - A thin client is a lightweight interface to the applica tion that does not have such operations like query databases, execute complex bu siness rules, or connect to legacy applications. What are types of J2EE clients? - Following are the types of J2EE clients: Applets Application clients Java Web Start-enabled rich clients, powered by Java Web Start technology. Wireless clients, based on Mobile Information Device Profile (MIDP) technology. What is deployment descriptor? - A deployment descriptor is an Extensible Markup Language (XML) text-based file with an .xml extension that describes a componen t s deployment settings. A J2EE application and each of its modules has its own de ployment descriptor. For example, an enterprise bean module deployment descripto r declares transaction attributes and security authorizations for an enterprise bean. Because deployment descriptor information is declarative , it can be changed without modifying the bean source code. At run time, the J2E E server reads the deployment descriptor and acts upon the component accordingly . What is the EAR file? - An EAR file is a standard JAR file with an .ear extensio n, named from Enterprise ARchive file. A J2EE application with all of its module s is delivered in EAR file. What is JTA and JTS? - JTA is the abbreviation for the Java Transaction API. JTS is the abbreviation for the Jave Transaction Service. JTA provides a standard i nterface and allows you to demarcate transactions in a manner that is independen t of the transaction manager implementation. The J2EE SDK implements the transac tion manager with JTS. But your code doesn t call the JTS methods directly. Instea d, it invokes the JTA methods, which then call the lower-level JTS routines. The refore, JTA is a high level transaction interface that your application uses to control transaction. and JTS is a low level transaction interface and ejb uses b ehind the scenes (client code doesn t directly interact with JTS. It is based on o bject transaction service(OTS) which is part of CORBA. What is JAXP? - JAXP stands for Java API for XML. XML is a language for represen ting and describing text-based data which can be read and handled by any program or tool that uses XML APIs. It provides standard services to determine the type of an arbitrary piece of data, encapsulate access to it, discover the operation s available on it, and create the appropriate JavaBeans component to perform tho se operations. What is J2EE Connector? - The J2EE Connector API is used by J2EE tools vendors a nd system integrators to create resource adapters that support access to enterpr ise information systems that can be plugged into any J2EE product. Each type of database or EIS has a different resource adapter. Note: A resource adapter is a

software component that allows J2EE application components to access and interac t with the underlying resource manager. Because a resource adapter is specific t o its resource manager, there is typically a different resource adapter for each type of database or enterprise information system. What is JAAP? - The Java Authentication and Authorization Service (JAAS) provide s a way for a J2EE application to authenticate and authorize a specific user or group of users to run it. It is a standard Pluggable Authentication Module (PAM) framework that extends the Java 2 platform security architecture to support use r-based authorization. What is Java Naming and Directory Service? - The JNDI provides naming and direct ory functionality. It provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes. Using JNDI, a J2EE application can store an d retrieve any type of named Java object. Because JNDI is independent of any spe cific implementations, applications can use JNDI to access multiple naming and d irectory services, including existing naming and directory services such as LDAP, NDS, DNS, and NIS. What is Struts? - A Web page development framework. Struts combines Java Servlet s, Java Server Pages, custom tags, and message resources into a unified framewor k. It is a cooperative, synergistic platform, suitable for development teams, in dependent developers, and everyone between. How is the MVC design pattern used in Struts framework? - In the MVC design patt ern, application flow is mediated by a central Controller. The Controller delega tes requests to an appropriate handler. The handlers are tied to a Model, and ea ch handler acts as an adapter between the request and the Model. The Model repre sents, or encapsulates, an application s business logic or state. Control is usual ly then forwarded back through the Controller to the appropriate View. The forwa rding can be determined by consulting a set of mappings, usually loaded from a d atabase or configuration file. This provides a loose coupling between the View a nd Model, which can make an application significantly easier to create and maint ain. Controller: Servlet controller which supplied by Struts itself; View: what you can see on the screen, a JSP page and presentation components; Model: System state and a business logic JavaBeans.