Java Beans Interview Preparation Guide
Download PDF

Java Beans Interview Questions and Answers will teach us now taht JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object. Learn JavaBeans or preparation of JavaBeans job with the help of this Java Beans Interview Questions with Answers guide

57 Java Beans Questions and Answers:

Table of Contents

Java Beans Interview Questions and Answers
Java Beans Interview Questions and Answers

1 :: What are Java Beans?

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.

2 :: Why do I get a NullPointerException when loading a JAR file into the BeanBox?

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.

3 :: What is bean persistance property?

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.

4 :: What are externizable interface?

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.

5 :: What are the purpose of introspection?

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.

6 :: What is property editor in java beans?

A property editor is a tool for customizing a particular property type. Property editors are activated in the Properties window. This window determines a property's type, searches for a relevant property editor, and displays the property's current value in a relevant way.

7 :: Write a simple bean program?

Write the SimpleBean code. Put it in a file named SimpleBean.java, in the directory of your choice. Here's the code:

import java.awt.Color;
import java.beans.XMLDecoder;
import javax.swing.JLabel;
import java.io.Serializable;

public class SimpleBean extends JLabel
implements Serializable {
public SimpleBean() {
setText( "Hello world!" );
setOpaque( true );
setBackground( Color.RED );
setForeground( Color.YELLOW );
setVerticalAlignment( CENTER );
setHorizontalAlignment( CENTER );
}
}

8 :: Difference between java bean and bean?

A Java Bean is a software component written in the Java programming language that conforms to the JavaBeans component specification. The JavaBeans APIs became part of the "core" Java APIs as of the 1.1 release of the JDK.
The JavaBeans specification defines a Java-based software component model that adds a number of features to the Java programming language. Some of these features include:

► introspection
► customization
► events
► properties
► persistence

Enterprise JavaBeans (EJBs) are Java-based software components that are built to comply with Java's EJB specification and run inside of an EJB container supplied by a J2EE provider. An EJB container provides distributed application functionality such as transaction support, persistence and lifecycle management for the EJBs.

9 :: What is a Bean? Why is not a Bean an Applet?

JavaBeans components, or Beans, are reusable software components that can be manipulated visually in a builder tool. Beans can be combined to create traditional applications, or their smaller web-oriented brethren, applets. In addition, applets can be designed to work as reusable Beans.

Individual Beans will function quite differently, but typical unifying features that distinguish a Bean are:

► Introspection: enables a builder tool to analyze how a Bean works
► Customization: enables a developer to use an app builder tool to customize the appearance and behavior of a Bean
► Events: enables Beans to communicate and connect together
► Properties: enable developers to customize and program with Beans
► Persistence: enables developers to customize Beans in an app builder, and then retrieve those Beans, with customized features intact, for future use.

10 :: Why are component architectures useful?

Developers are turning to creating components rather than monolithic applications to free themselves from slow, expensive application development, and to build up a portable, reusable code base. This enables developers to quickly attack new market opportunities, new joint development opportunities, and new ways to sell smaller packages of software.

11 :: Is JavaBeans a complete component architecture?

JavaBeans is a complete component model. It supports the standard component architecture features of properties, events, methods, and persistence. In addition, JavaBeans provides support for introspection (to allow automatic analysis of a JavaBeanscomponent) and customization (to make it easy to configure a JavaBeans component).

12 :: Why a component architecture for the Java platform?

JavaBeans brings the extraordinary power of the Java platform to component development, offering the ideal environment for a developer who wants to extend the concept of reusable component development beyond one platform and one architecture to embrace every platform and every architecture in the industry.

13 :: What kind of industry support exists for JavaBeans?

A coalition of industry leaders in component development worked with JavaSoft to create the JavaBeans specification, which was released to the Internet for public comments on September 4, 1996. The "frozen" JavaBeans specification combines the work of Apple, Borland, IBM, JustSystem, Microsoft, Netscape, Rogue Wave, SunSoft and Symantec and many, many others... We're very pleased to see the tools community swiftly embracing JavaBeans by announcing support for JavaBeans in their visual application builder tools.

14 :: Are there JavaBeans components available that I can buy today?

Yes. A large number of companies, both large and small, have announced their plans to deliver JavaBeans-based products.

15 :: Why nobody at Sun wants to read the messages sent to java-beans@java.sun.com?

Because of the fact, that 99% of all messages is spam. It is recommended to post on JavaBeans forum, which is inspected by Sun engineers on a regular basis.

16 :: What is the relationship between Sun s JFCs and JavaBeans?

The JFC (Java Foundation Classes) is based upon the AWT (Abstract Windowing Toolkit), which has been part of the Java platform from the beginning. JFC effectively adds a richer set of visual elements for building JavaBeans components and applications. See the JFC web site for more information.

17 :: Why do I get a duplicate name error when loading a JAR file?

The most common reason for a "java.lang.ClassFormatError: Duplicate name" error is that a .class file in the JAR contains a class whose class name is different from the expected name. So for example if you have a file called "a/B.class" and it contains a class called "B" or "a.X" instead of the class "a.B" then you will get this error.

Themost common causes for this problem are either forgetting to include a "package a;" statement or having a "package" statement with the wrong name.

18 :: What are the security implications for downloading Beans over the Internet?

JavaBeans does not add any security features to the Java platform. Rather, JavaBeans components have full access to the broad range of security features that are part of the Java platform. JavaBeans components can be used to build a range of different kinds of solutions from full-fledged Java desktop applications to web-based Applets.

19 :: When will JavaBeans be supported on the [fill in the blank] platform/operating system?

The complete set of JavaBeans APIs are core to Java 2, hence any platform that is fully compatible with Java 2 implicitly supports JavaBeans. Thus, JavaBeans support will be available as soon as this platform/operating system vendor supports Java 2.

20 :: What is entity reference?

A reference to an entity that is substituted for the reference when the XML document is parsed. It can reference a predefined entity such as < or reference one that is defined in the DTD. In the XML data, the reference could be to an entity that is defined in the local subset of the DTD or to an external XML file (an external entity). The DTD can also carve out a segment of DTD specifications and give it a name so that it can be reused (included) at multiple points in the DTD by defining a parameter entity.

21 :: What is an entity?

A distinct, individual item that can be included in an XML document by referencing it. Such an entity reference can name an entity as small as a character (for example, <, which references the less-than symbol or left angle bracket, <). An entity reference can also reference an entire document, an external entity, or a collection of DTD definitions.

22 :: What is enterprise bean provider?

An application developer who produces enterprise bean classes, remote and Interview Questions - Home interfaces, and deployment descriptor files, and packages them in an EJB JAR file.

23 :: What is Enterprise JavaBeans Query Language?

Defines the queries for the finder and select methods of an entity bean having container-managed persistence. A subset of SQL92, EJB QL has extensions that allow navigation over the relationships defined in an entity bean's abstract schema.

24 :: What is Enterprise JavaBeans?

A component architecture for the development and deployment of object-oriented, distributed, enterprise-level applications. Applications written using the Enterprise JavaBeans architecture are scalable, transactional, and secure.

25 :: What is enterprise information system?

The applications that constitute an enterprise's existing system for handling companywide information. These applications provide an information infrastructure for an enterprise. An enterpriseinformation system offers a well-defined set of services to its clients. These services are exposed to clients as local or remote interfaces or both. Examples of enterprise information systems include enterprise resource planning systems, mainframe transaction processing systems, and legacy database systems.