Sie sind auf Seite 1von 9

Amity School of Engineering and Technology Amity University UP

Advance Java Programming Tutorial Sheets


Tutorial Sheet 1 1 2 3 4 5 6 7 8 9 10 What is Remote Method Invocation? What are the advantages and disadvantages of using RMI over socket Explain RMI Architecture in detail? How many types of protocol implementations does RMI have? Explain the steps to create RMI application? What is the role of Stub and Skelton in RMI? What is the difference between Marshaling and Unmarshalling? Explain RMI Registry?. What is the functionality of Remote Reference Layer? What is the purpose of the following methods provided by the RMI bind() lookup() list() rebind() unbind() programming?

Naming class?

Tutorial Sheet 2 1. What is Swing? What is the difference between swing & AWT components ? 2. What do you mean by heavy weight and light weight components? 3. What is the difference between 1. Applet and JApplet 2 Frame and JFrame 4. What is the purpose of the enableEvents()method in swing? Explain with the help an example. 5. What class is at the top of the AWT event hierarchy? 6. Which Swing methods are thread-safe? 7. How are the elements of different layouts organized? 8. Why does JComponent have add() and remove() methods but Component does not? 9. How would you detect a keypress in a JComboBox? 10 Why wont the JVM terminate when I close all the application windows? Tutorial Sheet 3 1. What are the steps involved in establishing a JDBC connection? 2. What will Class.forName do while loading drivers? 3. How can you make the connection? 4. How can you create JDBC statements and what are they? 5. How can you retrieve data from the ResultSet? 6. What are the different types of Statements? 7. How can you use PreparedStatement? 8 What does setAutoCommit do? 9. How do you call a stored procedure from JDBC? 10 How can you move the cursor in scrollable result sets? How to Make Updates to updatable Result Sets?

Tutorial Sheet 4 1. Explain the life cycle methods of a Servlet. 2. What if the static modifier is removed from the signature of the main method? 3. Explain the directory structure of a web application. 4. What are the common mechanisms used for session tracking? 5. Explain how the concept of Cookies is used in session management? 6. What is Session ID? 7. Explain ServletContext? 8. What is pre-initialization of a servlet? 9. What is the difference between Difference between doGet() and doPost()? 10. What is the difference between HttpServlet and GenericServlet? Tutorial Sheet 5 1. What is the difference between ServletContext and ServletConfig? 2. Write a servlet program using database connectivity. 3. What is a output comment and Hidden comment? 4. What is an Expression in JSP? 5. What is a Declaration in JSP? 6. What is a Scriptlet and How to use it? 7. What are implicit objects? List them? Explain each object with example? 8. Difference between forward() and sendRedirect() method? 9. What are the different scope values for the <jsp:useBean>? 10. Explain the life-cycle methods in JSP?

Tutorial Sheet 6 1. What's the difference between an import and include directive, and also the difference between include directive and include action? 2. How can i connect from jsp to servlet page? 3. What is the difference between JSP ans servlet life cycle? 4. Explain the useBean Tag with the help of an example? 5. How do I prevent the output of my JSP or Servlet pages from being cached by the browser? 6. How does JSP handle run-time exceptions occurred in the program? 7. How can I implement a thread-safe JSP page? What are the advantages and Disadvantages of using it? 8. How do I use a scriptlet to initialize a newly instantiated bean? 9. How can I prevent the word "null" from appearing in my HTML input text fields ? 10. When I populate them with a resultset that has null values? Tutorial Sheet 7 1. What's a better approach for enabling thread-safe servlets and JSPs SingleThreadModel Interface or Synchronization? 2. How can I enable session tracking for JSP pages if the browser has disabled cookies? 3. What is jar file? How to create jar file in java? 4. What are JSP Actions? How do you pass data from JSP to servlet? 5. What is difference between Request scope and page scope? 6. Can JSP and Servlet share same Session and Beans? 7. What are the important steps in using JDBC in JSP? 8. How does variable scope work in JSP? 9. What do the differing levels of bean storage (page, session, app) mean? 10. How can we move from one JSP page to another JSP page?

Tutorial Sheet 8 1. What is the difference between getAttribute() anf getParameter() methods? 2. What is the difference application server and web server? 3. What do you mean by Enterprise Java Bean? 4. How EJB Invocation happens? AnsStep 1: Retrieve Home Object reference from Naming Service via JNDI. step 2: Return Home Object reference to the client. step 3: Create me a new EJB Object through Home Object interface. step 4: Create EJB Object from the Ejb Object step 5: Return EJB Object reference to the client. step 6: Invoke business method using EJB Object reference. step 7: Delegate request to Bean (Enterprise Bean).

5. The EJB container implements the EJBHome and EJBObject classes. For every request from a unique client, does the container create a separate instance of the generated EJBHome and EJBObject classes? 6. What are the different kinds of enterprise beans?What is Session Bean? Explain the lifecycle of stateless and stateful session bean? 7. What is Entity Bean? Explain the lifecycle of Container-Managed Persistent (CMP) bean and Bean-Managed Persistent(BMP) 8. What are the methods of Entity Bean? Ans- http://middlewares.wordpress.com/2008/05/02/what-are-the-methods-of-entity-beanexplain/ 9. What is the difference between Container-Managed Persistent (CMP) bean and Bean-Managed Persistent(BMP) ?

In container-managed persistence, entity bean data is automatically maintained by the container using a mechanism of its choosing. For example, a container implemented on top of an RDBMS may manage persistence by storing each bean?s data as a row in a table. Or, the container may use Java programming language serialization for persistence. When a bean chooses to have its persistence container managed, it specifies which of its fields are to be retained.
Ans-

In bean-managed persistence, the bean is entirely responsible for storing and retrieving its instance data. The EntityBean interface provides methods for the container to notify an instance when it needs to store or retrieve its data.
10. What are the callback methods in Entity beans? Ans- Callback methods allows the container to notify the bean of events in its life cycle. The
callback methods are defined in the javax.ejb.EntityBean interface. 1. setEntityContext() 2. ejbCreate() 3. ejbPostCreate() 4. ejbActivate() 5. ejbPassivate() 6. ejbRemove() 7. unsetEntityContext()

Tutorial Sheet 9 1. What is software architecture of EJB? 2. When should we use entity bean and session bean? Ans- Session beans are used to execute business logici.e in airline reservation entity beans are connected to database to get the data and give it to the session beans to update like suppose to reserve one seat::::::::entitybeans load the current reserved seats and give it to the session beans session beans update the current reserved seat and give it to the entity beans then entity beans save the updated data into the entity beanssuppose:entity bans load data like::::::::load(){seat 1,2,3,4,5,6.......... , 10 are reserved(entity beans load this data and send it to the}session beanssession beans do like:::::::::reserve(){reserve=seat10+1}in entity beans:::::::store(){ updateseat(reserve);}this reserve varible has give to the entity beans to save it into the database 2. What is the difference between ejb and servlet/jsp.? a)EJB Applications run on only Application Servers. Servlet/jsp's run on web/application servers. b)Ejbs allows Remote Accessing.
Ans-

Servlet/jsp's does not allow remote accessing c)Ejbs mainly usefull for implementing Business Logic(Model classes) Servlet's/jsp's are usefull for impementing View and Controller layers. D) EJB used as persistant layer. JSP used for presentation layer. Servlet we can use as controller.

Can Entity Beans have noCreate() methods?

Ans- Entity Beans can have no create() methods. Entity Beans have no create()
method, when entity bean is not used tostore the data in the database. In this case entity bean is used to retrieve the data from database.

Can the primary key in the entity bean be a Java primitive type such as int?

Ans- The primary key can't be a primitive type--use the primitive wrapper classes, instead. For example, you can use java.lang.Integer as the primary key class, but not int (it has to be a class, not a primitive) 6 Can you control when passivation occurs?

Ans- The developer, according to the specification, cannot directly control when
passivation occurs. Although for Stateful Session Beans, the container cannot passivate an instance that is inside a transaction. So using transactions can be a a strategy to control passivation. The ejbPassivate() method is called during passivation, so the developer has control over what to do during this exercise and can implement the require optimized logic. Some EJB containers, such as BEA WebLogic, provide the ability to tune the container to minimize passivation calls. Taken from the WebLogic 6.0 DTD -"The passivation-strategy can be either "default" or "transaction". With the default setting the container will attempt to keep a working set of beans in the cache. With the "transaction" setting, the container will passivate the bean after every transaction (or method call for a non-transactional invocation).

What is EJB QL? Brief description about local interfaces?

Ans- EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence. EJB QL is introduced in the EJB 2.0 specification. The EJB QL query language defines finder methods for entity beans with container managed persistenceand is portable across containers and persistence managers. EJB QL is used for queries of two types of finder methods: Finder methods that are defined in the home interface of an entity bean and which return entity objects. Select methods, which are not exposed to the client, but which are used by the Bean Provider to select persistent values that are maintained by the Persistence Manager or to select entity objects that are related to the entity bean on which the query is defined.

Local InterfacesEEJB was originally designed around remote invocation using the Java Remote Method Invocation (RMI) mechanism, and later extended to support to standard CORBA transport for these calls using RMI/IIOP. This design allowed for maximum flexibility in developing applications without consideration for the deployment scenario, and was a strong feature in support of a goal of component reuse in J2EE. Many developers are using EJBs locally -- that is, some or all of their EJB calls are between beans in a single container. With this feedback in mind, the EJB 2.0 expert group has created a local interface mechanism. The local interface may be defined for a bean during development, to allow streamlined calls to the bean if a caller is in the same container. This does not involve the overhead involved with RMI like marshalling etc. This facility will thus improve the performance of applications in which co-location is planned. Local interfaces also provide the foundation for container-managed relationships among entity beans with container-managed persistence.

8 What is the difference between Message Driven Beans and Stateless Session beans? Ans. Message-driven beans process multiple JMS messages asynchronously, rather than processing a serialized sequence of method calls. The most visible difference between message-driven beans and session and entity beans is that clients do not access messagedriven beans through interfaces. Interfaces are described in the section Defining Client Access with Interfaces. A message-driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously.

9. How can I call one EJB from inside of another EJB? What is an EJB Context? AnsJBs can be clients of other EJBs. It just works. Use JNDI to locate the Home Interface of the other bean, then acquire an instance reference, and so forth. 10. The EJB container implements the EJBHome and EJBObject classes. For every request from a unique client, does the container create a separate instance of the generated EJBHome and EJBObject classes? Tutorial Sheet 10 1. What is Struts? 2. What is Jakarta Struts Framework? 3. What is ActionServlet? 4. How you will make available any Message Resources Definitions file to the Struts Framework Environment? 5. What is Action Class? 6. What is ActionForm? 7. What is Struts Validator Framework? 8. Give the Details of XML files used in Validator Framework? 9. How you will display validation fail errors on jsp page? 10. How you will enable front-end validation based on the xml in validation.xml?

Das könnte Ihnen auch gefallen