<%@ include file="../../ga4.jsp" %> JavaBean Internals[State] - Quiz Explanation

JavaBean Internals - Quiz Explanation

The correct answers are indicated below, along with text that explains the correct answers.
 
1. The data part of a Bean is important because it:
  A. Is directly accessible by programmers.
  B. Allows programmers access to the internal state of the Bean.
  C. Completely describes the state of the Bean.
 
  1. The correct answer is C. The data part of a Bean is important because it completely describes the state of the Bean.
  2. A is incorrect because the data part of a Bean is never directly accessible by programmers.
  3. B is incorrect because the data portion of a Bean does not allow access to the internal state of the Bean, it is the internal state of the Bean.

2. The most important type of methods for accessing Beans are:
  A. Public methods.
  B. Private methods.
  C. Static methods.
 
  1. The correct answer is A.
  2. The most important type of methods for Beans are public methods since they provide the means by which Beans communicate with the outside world.
  3. B and C are incorrect because as useful as private and static methods are, they play no role in the external usage of a Bean.

3. An interface is a functionally related group of:
  A. Data.
  B. Beans.
  C. Publically defined methods.
  The correct answer is C.
An interface is a functionally related group of publically defined methods. A and B are incorrect because interfaces deal with groups of methods, not groups of data or Beans.

4. Indexed properties often include an additional pair of accessor methods because:
  A. There are so many elements.
  B. It is useful to be able to access either an individual element or the entire array of elements.
  C. It is strictly required that access be granted both to individual elements and the entire array of elements.
  The correct answer is B. Indexed properties often include an additional pair of accessor methods because it is useful to be able to access either an individual element or the entire array of elements. A is incorrect because the number of elements has nothing to do with the number of accessor methods. C is incorrect because a Bean isn't strictly required to support any of the accessor methods. However, at least one accessor method must be supported for a piece of Bean data to qualify as a property.

5. Individual elements of an indexed property are accessed through an accessor method using:
  A. An integer index.
  B. The location of the previous element.
  C. The name of the element.
  The correct answer is A.
Individual elements of an indexed property are accessed through an accessor method using an integer index. B and C are incorrect because the location of the previous element and the name of the element have nothing to do with how the element is accessed.

6. Bound properties are considered bound because they:
  A. Have limits on their values.
  B. Can't be written to.
  C. Notify an outside party whenever their value changes.
  The correct answer is C.
Bound properties are considered bound because they notify an outside party whenever their value changes. A is incorrect because there are no limits on the value of a bound property. B is incorrect because the ability to read or write a bound property is independent of the fact that the property is bound.

7. To reject the new value of a constrained property, a constrained property listener must:
  A. Set the property back to its previous value.
  B. Throw a PropertyVetoExceptionexception.
  C. call the vetoableChange()method.
  The correct answer is B.
To reject the new value of a constrained property, a constrained property listener must throw a PropertyVetoExceptionexception. A is incorrect because it is the Bean's responsibility, not the listener's, to set the property back to its previous value. C is incorrect because the vetoableChange() method is called automatically by the Bean when a constrained property value is changed; it should never be called directly by a listener.