Java Beans Interview Questions and Answers
Ques 1. What are Java Beans?
Ans. Java Beans are usual Java classes which adhere to certain coding conventions:
► Implements java.io.Serializable interface
► Provides no argument constructor
► Provides getter and setter methods for accessing it's properties.
Ques 2. Why do I get a NullPointerException when loading a JAR file into the BeanBox?Ans. Usually this is because of a mistake in the JAR file being loaded. In the meantime, typical errors include:
► The MANIFEST file uses classes using the wrong file separator ("/" should be used in all platforms).
► The MANIFEST file refers to classes in a package but the actual .class files are not really in that package.
Ques 3. What is bean persistance property?Ans. A bean has the property of persistence when its properties, fields, and state information are saved to and retrieved from storage. Component models provide a mechanism for persistence that enables the state of components to be stored in a non-volatile place for later retrieval.
Ques 4. What are externizable interface?Ans. Use the Externalizable interface when you need complete control over your bean's serialization (for example, when writing and reading a specific file format).
To use the Externalizable interface you need to implement two methods: readExternal and writeExternal. Classes that implement Externalizable must have a no-argument constructor.
Ques 5. What are the purpose of introspection?Ans. A growing number of Java object repository sites exist on the Internet in answer to the demand for centralized deployment of applets, classes, and source code in general. Any developer who has spent time hunting through these sites for licensable Java code to incorporate into a program has undoubtedly struggled with issues of how to quickly and cleanly integrate code from one particular source into an application.
The way in which introspection is implemented provides great advantages, including:
► Portability - Everything is done in the Java platform, so you can write components once, reuse them everywhere. There are no extra specification files that need to be maintained independently from your component code. There are no platform-specific issues to contend with. Your component is not tied to one component model or one proprietary platform. You get all the advantages of the evolving Java APIs, while maintaining the portability of your components.
► Reuse - By following the JavaBeans design conventions, implementing the appropriate interfaces, and extending the appropriate classes, you provide yourcomponent with reuse potential that possibly exceeds your expectations.
Most helpful rated by users: