Java EE (EJB, Servlets, JSP) Quiz
Test your knowledge of Enterprise Java Beans, Servlets, JSP, and Java web programming concepts
Questions
Which of the following aren't the methods for state/session management in the context of Servlets?
- Http Redirects
- Hidden Variables
- Cookies
- Rewritten URLs
- Using HttpSession Interface
The variables local to the methods like service(), doPost() and doGet() are thread safe. True/False?
- True
- False
You want to use URL rewriting to support client browsers, which do not use cookies. Which method will you use to attach the session id to a URL that is to be used for the sendRedirect() method of the HttpServletResponse?
- encodeURL
- encodeRedirectURL
- encodeSessionURL
- encodeSessionRedirectURL
- None of these
Which one of the following ServletRequest interface method returns more than one value associated with parameter?
- getParameterValue()
- getParameters()
- getParamValues()
- getParameterValues()
A transactional client receives TransactionRolledBackException from a call to a method on an entity bean. What could be the possible reason(s) for this?
- The bean method is throwing a checked exception and is configured with a transaction attribute of "Required".
- The bean method is throwing an unchecked exception and is configured with a transaction attribute of "Required".
- The bean does not throw an exception but is configured with a transaction attribute of "Mandatory".
- The bean method is throwing an unchecked exception and is configured with a transaction attribute of "Requires New".
Your application supports multiple client types including HTTP clients. Your business layer is implemented using Enterprise Java Beans. Which of the following is best suited for maintaining client state?
- Cookies
- Entity Beans
- HttpSession attributes
- Stateful session beans
- URL Rewriting
Which enterprise bean type is defined without any client view interfaces?
- BMP Entity bean
- CMP Entity bean
- Stateful Session bean
- Stateless Session bean
- Message Driven Bean
Which of the following is NOT an advantage of using the SessionFacade pattern?
- Hides model complexity from the client
- Reduces network traffic
- Provides a simple interface to the client
- Enables the client to control transactions
You want to locate an existing bean object but do not want to create a new instance, if an existing instance is not available. Which of the following bean attributes will you use in the jsp:useBean action?
- class
- type
- beanName
- class and type
- beanName and type
A container-managed persistence (CMP) entity bean A has a one-to-many unidirectional relationship (CMR) to another container-managed persistence (CMP) entity bean B. Which interface can expose the methods related to this relationship?
- Only local interface of bean A
- Local interfaces of both beans A and B
- Only local home interface of bean A
- Local home interfaces of both beans A and B
Which method cannot be called by a stateful session bean using bean-managed transactions?
- getUserTransaction()
- getRollbackOnly()
- getStatus()
- None of these
Which of the following statements are true about the given method declaration? MyEJBObject createWithName(String name) throws CreateException, RemoteException
- It is declared in the local home interface of a stateful session bean.
- It is declared in the local home interface of a stateless session bean.
- It is declared in the remote home interface of a stateful session bean.
- It is declared in the remote home interface of a stateless session bean.
Which of the following combinations (Design Pattern - Functionality) regarding Design Patterns is correct?
- Business Delegate - Reduces the coupling between presentation-tier clients and business services.
- Data Access Object - Multiple View using the same model.
- MVC - Enables easier migration to different persistence storage implementation.
- Value Object - Reduces Network Traffic
Classes in Java cannot be made static.
- True
- False
In Static inner classes, the data members and the member functions are by default static.
- True
- False
Annonymous Inner classes are not possible within an Interface.
- True
- False
Classes can be created at the runtime. ie; A class during its execution can create another class at the runtime, give it methods,decide what parameters should go into those methods, which all interfaces it should implement etc...
- True
- False
We all know about the Dynamic dispatch in java. But if there is dynamic dispatch , then is there a Static dispatch also? (Easy One...)
- True
- False