j2eeinterview questions

Upload: veena-kulkarni

Post on 14-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 j2eeinterview Questions

    1/9

    1) What is J2EE?J2EE 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.

    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?AppletsApplication clientsJava 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. Servlets are Java programming language that dynamically receive requests and make responses. JSP pages execute as servlets but allow a more natural approach to creating static content.

    5) What is JSF?

    JavaServer Faces (JSF) is a user interface (UI) designing framework for Java webapplications. JSF provide a set of reusable UI components, standard for web applications.JSF is based on MVC design pattern. It automatically saves the form data to server and populates the form date when display at client side.

    6) Define Hash tableHashTable is just like Hash Map,Collection having key(Unique),value pairs. Hashtable is a collection Synchronozed object .It does not allow duplicate values butit allows null values.

    7) What is Hibernate?Hibernate is a 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 more powerful association, inheritance, polymorphism, composition, and collections. It is a beautiful approach for persisting into database using the java objects. Hibernate also allows you to expressqueries 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 mapped in to the tables of a relational database using the metadata that describes the mapping between the objects and the database. It works by transforming thedata from one representation to another.

  • 7/27/2019 j2eeinterview Questions

    2/9

    11) Difference between save and saveorupdatesave() This method in hibernate is used to stores an object into the database. It insert an entry if the record doesnt exist, otherwise not.saveorupdate () -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 update method.

    12) Difference between load and get method?load() cant find the object from cache or database, an exception is thrown and the load() method never returns null.get() method returns null if the object cant be found. The load() method may return 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?ProductivityMaintainabilityPerformanceVendor independence

    15) What the Core interfaces are of hibernate framework?Session Interface

    SessionFactory InterfaceConfiguration InterfaceTransaction InterfaceQuery 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]org.hibernate.dialect.Oracle9Dialect andoracle.jdbc.driver.OracleDriver[/xml]full database can be replaced.

    19) How to add hibernate mapping file in hibernate configuration file?By

    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 object, 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. Hibernate 2 does not proxy objects by default.

    22) What do you create a SessionFactory?[java]Configuration cfg = new Configuration();

  • 7/27/2019 j2eeinterview Questions

    3/9

    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 expressqueries in its own portable SQL extension and this is called as HQL. It also allows 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 operations like query of databases, execute complex business rules, or connect tolegacy applications.

    26) Differentiate between .ear, .jar and .war files..jar files: These files are with the .jar extenstion. The .jar files contains the 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 applications.

    .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.DirectivesDeclarationsScripletsExpressions

    28) How to access web.xml init parameters from jsp page?For example, if you have: Id this is the value

    You can access this parameterId:

    29) What are JSP Directives?1.page Directives 2. include Directives: 3. taglib Directives

    30) What is the EAR file?An EAR file is a JAR file with an .ear extension. A J2EE application with all ofits 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]

  • 7/27/2019 j2eeinterview Questions

    4/9

    32) What is Struts?Struts framework is a Model-View-Controller(MVC) architecture for designing large scale applications. Which is combines of Java Servlets, JSP, Custom tags, andmessage. Struts helps you to create an extensible development environment for your application, based on published standards and proven design patterns. Model in many applications represent 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 andproducing 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 classActionServlet. 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 recordederror messages.The default implementation attempts to forward to the HTTP version of this method. Holding request parameters mapping and request and returnsset 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 bean become FormBean when extend org.apache.struts.action.ActionForm class. ActionForm 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 application.

    35) What is action mapping??In action mapping we specify action class for particular url ie path and diffrent target view ie forwards on to which request response will be forwarded.The 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 theAction class, enabling access to this 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 asa 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 andproducing 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 classActionServlet. This servlet is configured by defining a set of ActionMappings.

    37) What are different modules in spring?There are seven core modules in springThe Core container moduleO/R mapping module (Object/Relational)

    DAO moduleApplication context moduleAspect Oriented ProgrammingWeb moduleMVC module

    38) What is Bean Factory, have you used XMLBean factory?[java]XmlBeanFactory is one of the implementation of bean Factoryorg.springframework.beans.factory.xml.XmlBeanFactory is used to creat bean insta

  • 7/27/2019 j2eeinterview Questions

    5/9

    nce defined in our xml file.BeanFactory factory = new XmlBeanFactory(new FileInputStream(beans.xml));OrClassPathResource 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 enterprise application that resolves the complexity of enterprise application developmentalso providing a cohesive framework for J2EE application development. Which isprimarily based on IOC (inversion of control) or DI (dependency injection) design pattern.

    40) Functionality of ActionServlet and RequestProcessor?Receiving the HttpServletRequestPopulating JavaBean from the request parametersDisplaying response on the web page IssuesContent type issues handlingProvide extension points

    41) ActionServlet, RequestProcessor and Action classes are the components ofController

    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 server.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 objectsInitialization of properties is easy ? no need to read from properties fileapplication code is much easier to unit testObjects are created Lazily , Singleton configurationSprings configuration management services can be used in any architectural layer,in whatever runtime environment

    45) Lifecycle interfaces in spring ?[java]1) InitializingBeanpublic class ExpBean {public void init() { // do some initialization code }

    }ORpublic class ExpBean implements InitializingBean {public void afterPropertiesSet() { // do some initialization code }}2) DisposableBeanpublic class ExpBean {public void cleanup() {

  • 7/27/2019 j2eeinterview Questions

    6/9

    // do some destruction code (like releasing pooled connections)} }ORpublic class ExpBean implements DisposableBean {public void destroy() { // do some destruction code (like releasing pooled connections) }}[/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 exampleCalender c=Calender.getInstance();here Calender is a class and the method getInstance() is a Factory method whichcan create object for Calender class.

    47) What is servlet?Servlets is a server side components that provide a powerful mechanism for developing server side programs. Servlets is a server as well as platform-independentand Servlets are designed for a various protocols. Most commonly used HTTP protocols. Servlets uses 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 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 loadingServlet instantiationthe init methodRequest 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. Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multitiered J2EE environment to which the application 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 applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitiered, web-based applications.

    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 component

  • 7/27/2019 j2eeinterview Questions

    7/9

    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 components contains Business code, which is logicthat 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 data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves datafrom storage, processes it (if necessary), and sends it back to the client program.

    Is J2EE application only a web-based? - No, It depends on type of application that client wants. A J2EE application can be web-based or non-web-based. if an application client executes on the client machine, it is a non-web-based J2EE application. The J2EE application can provide a way for users to handle tasks such asJ2EE system or application administration. It typically has a graphical user interface created from Swing or AWT APIs, or a command-line interface. When user request, it can open an HTTP connection to establish communication with a servletrunning in the web tier.

    Are JavaBeans J2EE components? - No. JavaBeans components are not considered J2EE components by the J2EE specification. They are written to manage the data flowbetween an application client or applet and components running on the J2EE server or between server components and a database. JavaBeans components written forthe J2EE platform have instance variables and get and set methods for accessingthe data in the instance variables. JavaBeans components used in this way are typically simple in design and implementation, but should conform to the naming and design conventions outlined in the JavaBeans component architecture.

    Is HTML page a web component? - No. Static HTML pages and applets are bundled with web components during application assembly, but are not considered web components 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 servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating staticcontent.

    What is the container? - Containers are the interface between a component and the low-level platform specific functionality that supports the component. Beforea Web, enterprise bean, or application client component can be executed, it mustbe assembled into a J2EE application and deployed into its container.

    What are container services? - A container is a runtime support of a system-level entity. Containers provide components with services such as lifecycle management, security, deployment, and threading.

    What is the web container? - Servlet and JSP containers are collectively referred to as Web containers. It manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server.What is Enterprise JavaBeans (EJB) container? - It manages the execution of enterprise beans for J2EE applications.

  • 7/27/2019 j2eeinterview Questions

    8/9

    Enterprise beans and their container run on the J2EE server.

    What is Applet container? - IManages the execution of applets. Consists of a Webbrowser and Java Plugin running on the client together.

    How do we package J2EE components? - J2EE components are packaged separately andbundled into a J2EE application for deployment. Each component, its related files such as GIF and HTML files or server-side utility classes, and a deployment descriptor are assembled into a module and added to the J2EE application. A J2EEapplication is composed of one or more enterprise bean,Web, or application client component modules. The final enterprise solution can use one J2EE applicationor 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 describesa components deployment settings.

    What is a thin client? - A thin client is a lightweight interface to the application that does not have such operations like query databases, execute complex business rules, or connect to legacy applications.

    What are types of J2EE clients? - Following are the types of J2EE clients:AppletsApplication clientsJava 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 MarkupLanguage (XML) text-based file with an .xml extension that describes a components deployment settings. A J2EE application and each of its modules has its own deployment descriptor. For example, an enterprise bean module deployment descriptor declares transaction attributes and security authorizationsfor an enterprise bean. Because deployment descriptor information is declarative, it can be changed without modifying the bean source code. At run time, the J2EE 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 modules is delivered in EAR file.What is JTA and JTS? - JTA is the abbreviation for the Java Transaction API. JTSis the abbreviation for the Jave Transaction Service. JTA provides a standard interface and allows you to demarcate transactions in a manner that is independent of the transaction manager implementation. The J2EE SDK implements the transaction manager with JTS. But your code doesnt call the JTS methods directly. Instead, it invokes the JTA methods, which then call the lower-level JTS routines. Therefore, JTA is a high level transaction interface that your application uses tocontrol transaction. and JTS is a low level transaction interface and ejb uses behind the scenes (client code doesnt directly interact with JTS. It is based on object transaction service(OTS) which is part of CORBA.

    What is JAXP? - JAXP stands for Java API for XML. XML is a language for representing and describing text-based data which can be read and handled by any programor tool that uses XML APIs. It provides standard services to determine the typeof an arbitrary piece of data, encapsulate access to it, discover the operations available on it, and create the appropriate JavaBeans component to perform those operations.What is J2EE Connector? - The J2EE Connector API is used by J2EE tools vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged into any J2EE product. Each type ofdatabase or EIS has a different resource adapter. Note: A resource adapter is a

  • 7/27/2019 j2eeinterview Questions

    9/9

    software component that allows J2EE application components to access and interact with the underlying resource manager. Because a resource adapter is specific to its resource manager, there is typically a different resource adapter for eachtype of database or enterprise information system.

    What is JAAP? - The Java Authentication and Authorization Service (JAAS) provides a way for a J2EE application to authenticate and authorize a specific user orgroup of users to run it. It is a standard Pluggable Authentication Module (PAM)framework that extends the Java 2 platform security architecture to support user-based authorization.What is Java Naming and Directory Service? - The JNDI provides naming and directory functionality. It provides applications with methods for performing standarddirectory operations, such as associating attributes with objects and searchingfor objects using their attributes. Using JNDI, a J2EE application can store and retrieve any type of named Java object. Because JNDI is independent of any specific implementations, applications can use JNDI to access multiple naming and directory services, including existing naming anddirectory services such as LDAP, NDS, DNS, and NIS.

    What is Struts? - A Web page development framework. Struts combines Java Servlets, Java Server Pages, custom tags, and message resources into a unified framework. It is a cooperative, synergistic platform, suitable for development teams, independent developers, and everyone between.

    How is the MVC design pattern used in Struts framework? - In the MVC design pattern, application flow is mediated by a central Controller. The Controller delegates requests to an appropriate handler. The handlers are tied to a Model, and each handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an applications business logic or state. Control is usually then forwarded back through the Controller to the appropriate View. The forwarding can be determined by consulting a set of mappings, usually loaded from a database or configuration file. This provides a loose coupling between the View and Model, which can make an application significantly easier to create and maintain. Controller: Servlet controller which supplied by Struts itself; View: whatyou can see on the screen, a JSP page and presentation components; Model: Systemstate and a business logic JavaBeans.