Thursday, October 25, 2007

J2EE Interview Questions Part6


Question I made my class Cloneable but I still get 'Can't access protected method clone. Why? (CoreJava)
Answer Yeah, some of the Java books, in particular "The Java Programming Language", imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that's not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn't do anything special and just calls super.clone().

Question Why is XML such an important development? (XML)
Answer It removes two constraints which were holding back Web developments:
1. § dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for;
2. the complexity of full SGML, whose syntax allows many powerful but hard-to-program options.
§ XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.
Question Are enterprise beans allowed to use Thread.sleep()? (EJB)
Answer Enterprise beans make use of the services provided by the EJB container, such as life-cycle management. To avoid conflicts with these services, enterprise beans are restricted from performing certain operations: Managing or synchronizing threads

Question Is it possible to write two EJB's that share the same Remote and Home interfaces, and have different bean classes? if so, what are the advantages/disadvantages? (EJB)
Answer It's certainly possible. In fact, there's an example that ships with the Inprise Application Server of an Account interface with separate implementations for CheckingAccount and SavingsAccount, one of which was CMP and one of which was BMP.

Question Is it possible to specify multiple JNDI names when deploying an EJB? (EJB)
Answer No. To achieve this you have to deploy your EJB multiple times each specifying a different JNDI name.

Question Is there any way to force an Entity Bean to store itself to the db? I don't wanna wait for the container to update the db, I want to do it NOW! Is it possible? (EJB)
Answer Specify the transaction attribute of the bean as RequiresNew. Then as per section 11.6.2.4 of the EJB v 1.1 spec EJB container automatically starts a new transaction before the method call. The container also performs the commit protocol before the method result is sent to the client.

0 comments:

Advertisement

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com