Java Bean Bound Property Change Notification
Short answer
C The program outputs Changed to Java because the listener is notified after the name field is updated.
Question

Key Takeaways
The core concept is that a bound property fires a change event to listeners only after the field has been successfully updated, leading to the output reflecting the new state.
This question tests the behavior of Java Beans bound properties using PropertyChangeSupport. It establishes that listeners are notified with the new value after the setter updates the internal state.
Common mistake: Candidates often select 'Changed to Test' because they mistakenly believe the listener sees the old value or that the change is not propagated immediately.
Expert Analysis
Why the Answer Is Correct
The code utilizes PropertyChangeSupport to implement a bound property pattern in a Java Bean. In the setName method, the assignment this.name = newName; occurs first, updating the object's state. Subsequently, firePropertyChange is called, which notifies registered listeners. Since the field is already updated when the notification fires, any listener printing the value will see "Java". Therefore, the output is "Changed to Java".
Why the Other Options Are Wrong
Option D is incorrect because it assumes the listener receives the old value or that the update happens asynchronously later; however, the standard implementation updates the field before firing the event. Option B is incorrect because the code adheres to valid Java syntax and the JavaBeans specification for bound properties. Option A is incorrect because the listener explicitly prints a message.
Community Comment Notes
Community consensus strongly supports option C. Users like ASpushkin highlighted that bound properties notify listeners when their value changes, implying the listener sees the current state. Another user confirmed that when set is called, the new value is set and then the listener is fired with that new value.
Exam Strategy
When analyzing Java Bean property change events, always check the order of operations in the setter: does it update the field before or after calling firePropertyChange? The standard convention is update-then-fire.
Frequently Asked Questions
Does firePropertyChange send the old or new value?
Why is this considered a bound property?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 3 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 3
-
ASPushkin 👍 1answer: C Bound Properties A bound property notifies listeners when its value changes. This has two implications: When a bound property is changed, the bean sends a PropertyChangeEvent to its registered listeners. public PropertyChangeSupport(Object sourceBean) public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
-
d7bb0b2 👍 1 Answered CIs correct, when set is called set the new value , and fire sout listener WITH NEW VALUE
-
Omnisumem 👍 1 Answered Ctested
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.